feat: Update devcontainer setup with Dockerfile and improved script for pre-commit hooks
All checks were successful
Lint / pre-commit Linting (push) Successful in 1m37s

This commit is contained in:
2025-12-26 01:17:16 +01:00
parent eb3a74b709
commit 4c12baef28
3 changed files with 11 additions and 11 deletions

View File

@@ -0,0 +1,7 @@
# .devcontainer/Dockerfile
FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye
# CACHED INSTALLATION:
# Install global NPM packages here. This creates a cached Docker layer.
# We use 'su node' to ensure permissions are correct for the non-root user.
RUN su node -c "npm install -g @google/gemini-cli"

View File

@@ -11,9 +11,7 @@
}, },
"ghcr.io/devcontainers/features/git:1": {}, "ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/git-lfs:1": {}, "ghcr.io/devcontainers/features/git-lfs:1": {},
"ghcr.io/devcontainers-extra/features/pipx-package:1": { "ghcr.io/devcontainers-extra/features/pre-commit:2": {}
"packages": "pre-commit, ruff"
}
}, },
"customizations": { "customizations": {
"vscode": { "vscode": {
@@ -30,13 +28,13 @@
} }
} }
}, },
"postCreateCommand": "npm install",
"postStartCommand": "bash .devcontainer/setup.sh", "postStartCommand": "bash .devcontainer/setup.sh",
"remoteUser": "node", "remoteUser": "vscode",
"updateRemoteUserUID": true,
"mounts": [ "mounts": [
"source=pipx-venvs,target=/home/node/.local/share/pipx,type=volume", "source=pipx-venvs,target=/home/node/.local/share/pipx,type=volume",
"source=pipx-bin,target=/home/node/.local/bin,type=volume", "source=pipx-bin,target=/home/node/.local/bin,type=volume",
"source=pre-commit-cache,target=/home/node/.cache/pre-commit,type=volume", "source=pre-commit-cache,target=/home/node/.cache/pre-commit,type=volume",
"source=${localEnv:HOME}/.gemini,target=/home/node/.gemini,type=bind" "source=${localEnv:USERPROFILE}/.gemini,target=/home/node/.gemini,type=bind"
] ]
} }

View File

@@ -1,16 +1,11 @@
#!/bin/bash #!/bin/bash
# 1. Fix Git Permissions (Critical in Docker) # 1. Fix Git Permissions (Critical in Docker)
sudo chown -R $(whoami) .git
git config --global --add safe.directory $(pwd) git config --global --add safe.directory $(pwd)
# 2. Re-connect Git Hooks # 2. Re-connect Git Hooks
# 'pre-commit install' is idempotent (it checks if the hook exists and exits fast).
# It's safe to run on every start.
if command -v pre-commit &> /dev/null; then if command -v pre-commit &> /dev/null; then
pre-commit install pre-commit install
else else
echo "⚠️ Warning: pre-commit not found. Skipping hook installation." echo "⚠️ Warning: pre-commit not found. Skipping hook installation."
fi fi
# We REMOVED 'npm install' from here to speed up your daily workflow.