Skip to content

Commit cf73fee

Browse files
MohsinHashmi-DataInnmohsin-wiserclaude
authored
fix(devcontainer): bake tools into image and fix workspace path (#326)
- remove features from devcontainer.json (now in Dockerfile) - add Docker CLI and GitHub CLI to Dockerfile - remove hardcoded workspace mount from docker-compose.yml - let DevPod handle workspace mounting automatically - simplify post-create.sh 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Mohsin Hashmi <mhashmi@wiser.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 70f12fc commit cf73fee

4 files changed

Lines changed: 45 additions & 88 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,36 @@ FROM mcr.microsoft.com/devcontainers/java:21-bookworm
77
ARG NODE_VERSION="20"
88
RUN su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"
99

10-
# Install additional system dependencies
10+
# ============================================
11+
# INSTALL TOOLS (baked in for faster startup)
12+
# ============================================
13+
14+
# Install Docker CLI and Docker Compose
15+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
16+
&& apt-get -y install --no-install-recommends \
17+
apt-transport-https \
18+
ca-certificates \
19+
curl \
20+
gnupg \
21+
lsb-release \
22+
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
23+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list \
24+
&& apt-get update \
25+
&& apt-get -y install --no-install-recommends docker-ce-cli docker-compose-plugin \
26+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
27+
28+
# Install GitHub CLI
29+
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
30+
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
31+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list \
32+
&& apt-get update \
33+
&& apt-get -y install --no-install-recommends gh \
34+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
35+
36+
# ============================================
37+
# INSTALL SYSTEM DEPENDENCIES
38+
# ============================================
39+
1140
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
1241
&& apt-get -y install --no-install-recommends \
1342
postgresql-client \
@@ -40,50 +69,8 @@ ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
4069
# Install global npm packages
4170
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g npm@latest" 2>&1
4271

43-
# ============================================
44-
# PRE-CACHE DEPENDENCIES FOR FASTER STARTUP
45-
# ============================================
46-
47-
# Create cache directories
48-
RUN mkdir -p /home/vscode/.npm-cache /home/vscode/.m2-cache \
49-
&& chown -R vscode:vscode /home/vscode/.npm-cache /home/vscode/.m2-cache
50-
51-
# --- NPM Dependencies ---
52-
# Copy package files for dependency caching
53-
COPY --chown=vscode:vscode package*.json /tmp/deps/
54-
COPY --chown=vscode:vscode apps/frontend/package*.json /tmp/deps/apps/frontend/
55-
56-
# Install root npm dependencies
57-
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && cd /tmp/deps && npm install" 2>&1
58-
59-
# Install frontend npm dependencies
60-
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && cd /tmp/deps/apps/frontend && npm install --legacy-peer-deps" 2>&1
61-
62-
# --- Maven Dependencies ---
63-
# Copy pom.xml for Maven dependency caching
64-
COPY --chown=vscode:vscode apps/backend/pom.xml /tmp/deps/apps/backend/
65-
COPY --chown=vscode:vscode apps/backend/.mvn /tmp/deps/apps/backend/.mvn/
66-
COPY --chown=vscode:vscode apps/backend/mvnw /tmp/deps/apps/backend/
67-
68-
# Download Maven dependencies
69-
RUN cd /tmp/deps/apps/backend \
70-
&& chmod +x mvnw \
71-
&& ./mvnw dependency:go-offline -B -q || true
72-
73-
# Move cached dependencies to persistent locations
74-
RUN cp -r /tmp/deps/node_modules /home/vscode/.npm-cache/root-node_modules 2>/dev/null || true \
75-
&& cp -r /tmp/deps/apps/frontend/node_modules /home/vscode/.npm-cache/frontend-node_modules 2>/dev/null || true \
76-
&& chown -R vscode:vscode /home/vscode/.npm-cache /home/vscode/.m2
77-
78-
# Cleanup temp files
79-
RUN rm -rf /tmp/deps
80-
81-
# ============================================
82-
# END DEPENDENCY CACHING
83-
# ============================================
84-
8572
# Set working directory
86-
WORKDIR /workspaces/SimpleAccounts-UAE
73+
WORKDIR /workspaces
8774

8875
# Default command
8976
CMD ["sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,8 @@
44
"service": "devcontainer",
55
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
66

7-
// Features to add to the dev container
8-
"features": {
9-
"ghcr.io/devcontainers/features/docker-in-docker:2": {
10-
"moby": true,
11-
"installDockerBuildx": true
12-
},
13-
"ghcr.io/devcontainers/features/git:1": {
14-
"ppa": true,
15-
"version": "latest"
16-
},
17-
"ghcr.io/devcontainers/features/github-cli:1": {}
18-
},
7+
// Docker CLI, GitHub CLI, and Git are pre-installed in the image
8+
// No features needed - everything is baked into the Dockerfile for faster startup
199

2010
// Configure tool-specific properties
2111
"customizations": {

.devcontainer/docker-compose.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.8'
2-
31
services:
42
devcontainer:
53
image: ghcr.io/simpleaccounts/simpleaccounts-uae-devcontainer:latest
@@ -8,7 +6,6 @@ services:
86
# context: ..
97
# dockerfile: .devcontainer/Dockerfile
108
volumes:
11-
- ..:/workspaces/SimpleAccounts-UAE:cached
129
- devcontainer-vscode-extensions:/home/vscode/.vscode-server/extensions
1310
- devcontainer-maven-cache:/home/vscode/.m2
1411
- devcontainer-npm-cache:/home/vscode/.npm

.devcontainer/post-create.sh

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,24 @@ set -e
55

66
echo "🚀 Setting up SimpleAccounts-UAE development environment..."
77

8-
# --- Use cached npm dependencies if available ---
9-
if [ -d "/home/vscode/.npm-cache/root-node_modules" ]; then
10-
echo "📦 Restoring cached root npm dependencies..."
11-
cp -r /home/vscode/.npm-cache/root-node_modules ./node_modules
12-
# Quick install to sync any new packages
13-
npm install --prefer-offline 2>/dev/null || npm install
14-
else
15-
echo "📦 Installing root npm dependencies..."
16-
npm install
17-
fi
8+
# Install root dependencies
9+
echo "📦 Installing root npm dependencies..."
10+
npm install
1811

19-
if [ -d "/home/vscode/.npm-cache/frontend-node_modules" ]; then
20-
echo "📦 Restoring cached frontend npm dependencies..."
21-
cp -r /home/vscode/.npm-cache/frontend-node_modules ./apps/frontend/node_modules
22-
# Quick install to sync any new packages
23-
cd apps/frontend
24-
npm install --legacy-peer-deps --prefer-offline 2>/dev/null || npm install --legacy-peer-deps
25-
cd ../..
26-
else
27-
echo "📦 Installing frontend dependencies..."
28-
cd apps/frontend
29-
npm install --legacy-peer-deps
30-
cd ../..
31-
fi
12+
# Install frontend dependencies
13+
echo "📦 Installing frontend dependencies..."
14+
cd apps/frontend
15+
npm install --legacy-peer-deps
16+
cd ../..
3217

3318
# Install Playwright browsers (using system Chromium)
3419
echo "🎭 Setting up Playwright..."
3520
cd apps/frontend
3621
npx playwright install-deps 2>/dev/null || true
3722
cd ../..
3823

39-
# Maven dependencies are cached in ~/.m2 which is a named volume
40-
# Just ensure any new dependencies are downloaded
41-
echo "☕ Syncing Maven dependencies..."
24+
# Download Maven dependencies
25+
echo "☕ Downloading Maven dependencies..."
4226
cd apps/backend
4327
if [ -f "./mvnw" ]; then
4428
chmod +x ./mvnw
@@ -77,6 +61,5 @@ fi
7761
echo "✅ Development environment setup complete!"
7862
echo ""
7963
echo "Quick start commands:"
80-
echo " Frontend: npm run frontend"
81-
echo " Backend: npm run backend:run"
82-
echo " Tests: npm test"
64+
echo " Frontend: cd apps/frontend && npm run dev"
65+
echo " Backend: cd apps/backend && ./mvnw spring-boot:run"

0 commit comments

Comments
 (0)