Skip to content

Commit

Permalink
try docker your docker by running docker in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftbj committed Jan 9, 2025
1 parent 7af7946 commit 6c6152a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/docker/Dockerfile.monorepo
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ RUN --mount=type=cache,target=/var/lib/apt/lists/,sharing=private \
export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y curl gpg language-pack-en-base software-properties-common \
# Install Docker CLI
&& install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
&& chmod a+r /etc/apt/keyrings/docker.gpg \
&& echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" > /etc/apt/sources.list.d/docker.list \
&& add-apt-repository ppa:ondrej/php \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& apt-get update \
&& apt-get --purge install -y \
git \
unzip \
zip \
docker-ce-cli \
docker-compose-plugin \
"php${PHP_VERSION}" \
"php${PHP_VERSION}-cli" \
"php${PHP_VERSION}-curl" \
Expand Down
27 changes: 27 additions & 0 deletions tools/docker/bin/monorepo
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@ echo "Running command in monorepo container: $*"
# Source the versions file
source "$MONOREPO_ROOT/.github/versions.sh"

# Pre-pull Docker images if this is a docker command
if [ "$1" = "pnpm" ] && [ "$2" = "jetpack" ] && [ "$3" = "docker" ] && [ "$4" = "up" ]; then
echo "Pre-pulling required Docker images..."
# Ensure MySQL data directory exists
mkdir -p "$MONOREPO_ROOT/tools/docker/data/jetpack_dev_mysql"
# Ensure SSH keys directory exists
mkdir -p "$MONOREPO_ROOT/tools/docker/data/ssh.keys"
# Only pull images that aren't present
if ! docker image inspect mariadb:lts >/dev/null 2>&1; then
docker pull mariadb:lts
fi
if ! docker image inspect automattic/jetpack-wordpress-dev:latest >/dev/null 2>&1; then
docker pull automattic/jetpack-wordpress-dev:latest
fi
if ! docker image inspect phpmyadmin/phpmyadmin:latest >/dev/null 2>&1; then
docker pull --platform linux/arm64 phpmyadmin/phpmyadmin:latest
fi
if ! docker image inspect maildev/maildev >/dev/null 2>&1; then
docker pull --platform linux/arm64 maildev/maildev
fi
if ! docker image inspect atmoz/sftp >/dev/null 2>&1; then
docker pull --platform linux/arm64 atmoz/sftp
fi
fi

# Build the image if it doesn't exist
if ! docker image inspect jetpack-monorepo:latest >/dev/null 2>&1; then
if [ "${BUILD_LOCAL:-}" = "1" ]; then
Expand All @@ -37,9 +62,11 @@ fi
docker run --rm -it \
-v "$MONOREPO_ROOT:/workspace" \
-v "$MONOREPO_ROOT/tools/docker/data/monorepo:/root" \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /workspace \
-e TERM=$TERM \
-e COLORTERM=$COLORTERM \
-e DOCKER_ROOT="$MONOREPO_ROOT/tools/docker" \
-e NPM_CONFIG_USERCONFIG=/root/.npmrc \
-e NPM_CONFIG_CACHE=/root/.npm \
-e PNPM_HOME=/root/.local/share/pnpm \
Expand Down

0 comments on commit 6c6152a

Please sign in to comment.