Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .devcontainer/.devcontainer-cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# devcontainer build cache configuration
# This file is used to improve build performance by caching layers

# Enable Docker BuildKit for better caching
DOCKER_BUILDKIT=1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Ensure BuildKit is actually enabled during devcontainer builds
Setting DOCKER_BUILDKIT=1 is correct, but verify that this file is consumed by your build invocation (e.g., via --env-file or equivalent in devcontainer.json). Without loading it, BuildKit won’t be enabled and layer caching won’t apply.

Run this script to confirm references to .devcontainer-cache exist in your config:


🏁 Script executed:

#!/bin/bash
# Verify that .devcontainer/.devcontainer-cache is referenced in devcontainer.json
rg --fixed-strings --line-number ".devcontainer-cache" -n

Length of output: 57


Add the cache env-file to your devcontainer configuration
It appears .devcontainer/.devcontainer-cache is never referenced in your devcontainer.json, so BuildKit won’t actually be enabled. You need to load that file via the build.envFile (or runArgs: ["--env-file", ...]) property.

Locations to update:

  • devcontainer.json (at project root)

Suggested change:

--- devcontainer.json
+++ devcontainer.json
@@
   "build": {
     "dockerfile": "Dockerfile",
-    // …other build options
+    "envFile": [
+      ".devcontainer/.devcontainer-cache"
+    ]
   },
   // …other config

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In .devcontainer/.devcontainer-cache at line 5, the environment variable
DOCKER_BUILDKIT=1 is set but this file is not referenced in devcontainer.json,
so BuildKit is not enabled during builds. To fix this, update devcontainer.json
at the project root to include the .devcontainer/.devcontainer-cache file in the
build.envFile property or add it to runArgs with --env-file. This ensures the
environment variable is loaded and BuildKit is activated for caching.


# Set cache mount points for common directories
CACHE_DIRS="/tmp/.npm-cache:/home/linuxbrew/.linuxbrew/var/cache"
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"remoteEnv": {
"SSH_AUTH_SOCK": "/home/vscode/.1password/agent.sock"
},
// "postStartCommand": "zsh -c 'eval \"$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\" && source ~/.zshrc'",
"postCreateCommand": "zsh -c 'eval \"$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\" && source ~/.zshrc'",
"remoteUser": "vscode",
"customizations": {
"vscode": {
Expand Down
43 changes: 30 additions & 13 deletions .devcontainer/features/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,51 @@ echo "Current working directory: $(pwd)"
echo "User: $(whoami)"
echo "Home directory: $HOME"

if ! command -v npm >/dev/null 2>&1; then
echo "npm not found, skipping npm package installation."
exit 0
fi

NPM_CACHE_DIR="/tmp/.npm-cache"
mkdir -p "$NPM_CACHE_DIR"
npm config set cache "$NPM_CACHE_DIR" --global

GLOBAL_JSON_PATHS=(
"npm/global.json"
"/workspace/npm/global.json"
"/workspaces/*/npm/global.json"
"/workspace/npm/global.json"
"$HOME/npm/global.json"
"/tmp/build/npm/global.json"
"npm/global.json"
)

GLOBAL_JSON_FILE=""
for path in ${GLOBAL_JSON_PATHS[@]}; do
for file in $path; do
if [ -f "$file" ]; then
GLOBAL_JSON_FILE="$file"
for path in "${GLOBAL_JSON_PATHS[@]}"; do
if [[ "$path" == *"*"* ]]; then
found_file=$(find / -path "$path" -type f 2>/dev/null | head -n 1)
if [ -n "$found_file" ]; then
GLOBAL_JSON_FILE="$found_file"
echo "Found npm/global.json at: $GLOBAL_JSON_FILE"
break 2
break
fi
done
elif [ -f "$path" ]; then
GLOBAL_JSON_FILE="$path"
echo "Found npm/global.json at: $GLOBAL_JSON_FILE"
break
fi
done

if [ -z "$GLOBAL_JSON_FILE" ]; then
echo "Warning: npm/global.json not found in any of the expected locations:"
for path in ${GLOBAL_JSON_PATHS[@]}; do
echo " - $path"
done
printf ' - %s\n' "${GLOBAL_JSON_PATHS[@]}"
echo "Skipping npm package installation."
exit 0
fi

npm install -g $(jq -r '.dependencies | keys[]' "$GLOBAL_JSON_FILE")
packages=$(jq -r '.dependencies | keys[]' "$GLOBAL_JSON_FILE" 2>/dev/null || echo "")
if [ -n "$packages" ]; then
echo "Installing npm packages: $packages"
npm install -g $packages --prefer-offline --no-audit --no-fund
else
echo "No packages found in global.json dependencies"
fi

echo "Feature installation completed. Configuration will be applied by postCreateCommand."