Skip to content

Commit

Permalink
move store and run pnpm install on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftbj committed Jan 9, 2025
1 parent 469d54b commit 0106e56
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,5 @@ phpcs.xml
*.code-workspace
/.vscode/settings.json

.pnpm-store/
.pnpm-debug.log
.pnpm-error.log
19 changes: 16 additions & 3 deletions tools/docker/bin/monorepo
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@ source "$MONOREPO_ROOT/.github/versions.sh"

# Build the image if it doesn't exist
if ! docker image inspect jetpack-monorepo:latest >/dev/null 2>&1; then
echo "Pulling monorepo image..."
docker pull automattic/jetpack-monorepo:latest
docker tag automattic/jetpack-monorepo:latest jetpack-monorepo:latest
if [ "${BUILD_LOCAL:-}" = "1" ]; then
echo "Building monorepo image locally..."
docker build \
--build-arg PHP_VERSION="$PHP_VERSION" \
--build-arg COMPOSER_VERSION="$COMPOSER_VERSION" \
--build-arg NODE_VERSION="$NODE_VERSION" \
--build-arg PNPM_VERSION="$PNPM_VERSION" \
-t jetpack-monorepo:latest \
-f "$MONOREPO_ROOT/tools/docker/Dockerfile.monorepo" \
"$MONOREPO_ROOT/tools/docker"
else
echo "Pulling monorepo image..."
docker pull automattic/jetpack-monorepo:latest
docker tag automattic/jetpack-monorepo:latest jetpack-monorepo:latest
fi
fi

# Run the command in the container
Expand All @@ -31,5 +43,6 @@ docker run --rm -it \
-e NPM_CONFIG_USERCONFIG=/root/.npmrc \
-e NPM_CONFIG_CACHE=/root/.npm \
-e PNPM_HOME=/root/.local/share/pnpm \
-e PNPM_STORE_DIR=/root/.pnpm-store \
jetpack-monorepo:latest \
"$@"
13 changes: 13 additions & 0 deletions tools/docker/bin/monorepo-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Exit on error
set -e

# Check if jetpack command is available
if ! pnpm jetpack --help >/dev/null 2>&1; then
echo "Setting up Jetpack CLI..."
pnpm install
fi

# Execute the passed command
exec "$@"

0 comments on commit 0106e56

Please sign in to comment.