Skip to content

Commit e4b7017

Browse files
MohsinHashmi-DataInnmohsin-wiserclaudenazia-datainn
authored
chore(devcontainer): optimize prebuilt image performance (#328)
* fix(devcontainer): add workspace mount to docker-compose - add explicit workspace mount ../:/workspaces/SimpleAccounts-UAE - use fixed workspace path instead of variable - fixes 'lstat /workspaces/content: no such file or directory' error 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore(devcontainer): optimize prebuilt image performance - Bake Playwright system dependencies into Dockerfile - Combine apt-get layers for efficiency - Pre-cache Maven and NPM dependencies during build - Update post-create.sh to utilize pre-seeded caches --------- Co-authored-by: Mohsin Hashmi <mhashmi@wiser.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: nazia-datainn <nazia@datainn.io>
1 parent 12d24dd commit e4b7017

2 files changed

Lines changed: 71 additions & 19 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,39 @@ RUN su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${N
1111
# INSTALL TOOLS (baked in for faster startup)
1212
# ============================================
1313

14-
# Install Docker CLI and Docker Compose
14+
# SimpleAccounts-UAE Development Container
15+
# Base image with Node 20 and Java 21 for full-stack development
16+
17+
FROM mcr.microsoft.com/devcontainers/java:21-bookworm
18+
19+
# Install Node.js 20
20+
ARG NODE_VERSION="20"
21+
RUN su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"
22+
23+
# ============================================
24+
# INSTALL TOOLS (baked in for faster startup)
25+
# ============================================
26+
27+
# Install Docker CLI, Docker Compose, GitHub CLI, and System Dependencies
1528
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
1629
&& apt-get -y install --no-install-recommends \
1730
apt-transport-https \
1831
ca-certificates \
1932
curl \
2033
gnupg \
2134
lsb-release \
35+
# Docker Setup
2236
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
2337
&& 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 \
38+
# GitHub CLI Setup
39+
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
3040
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
3141
&& 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 \
3242
&& 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-
40-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4143
&& apt-get -y install --no-install-recommends \
44+
docker-ce-cli \
45+
docker-compose-plugin \
46+
gh \
4247
postgresql-client \
4348
redis-tools \
4449
chromium \
@@ -60,6 +65,27 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
6065
libxfixes3 \
6166
libxrandr2 \
6267
xdg-utils \
68+
# Playwright / WebKit / Firefox dependencies
69+
gstreamer1.0-libav \
70+
gstreamer1.0-plugins-bad \
71+
gstreamer1.0-plugins-base \
72+
gstreamer1.0-plugins-good \
73+
hunspell-en-us \
74+
libavcodec59 \
75+
libavformat59 \
76+
libavutil57 \
77+
libenchant-2-2 \
78+
libsecret-1-0 \
79+
libhyphen0 \
80+
libmanette-0.2-0 \
81+
libgles2 \
82+
libopus0 \
83+
libwebpdemux2 \
84+
libwoff1 \
85+
libharfbuzz-icu0 \
86+
libevdev2 \
87+
libnotify4 \
88+
libflite1 \
6389
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
6490

6591
# Set Playwright to use system Chromium
@@ -69,7 +95,33 @@ ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
6995
# Install global npm packages
7096
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g npm@latest" 2>&1
7197

72-
# Set working directory
98+
# ============================================
99+
# PRE-CACHE DEPENDENCIES
100+
# ============================================
101+
102+
USER vscode
103+
104+
# Pre-cache Maven dependencies
105+
# Copy pom.xml files (and parent poms if needed) to a temp directory
106+
WORKDIR /tmp/backend
107+
COPY --chown=vscode:vscode apps/backend/pom.xml .
108+
# Run go-offline to download dependencies to ~/.m2/repository
109+
RUN mvn dependency:go-offline -B -q
110+
111+
# Pre-cache NPM dependencies
112+
WORKDIR /tmp/root
113+
COPY --chown=vscode:vscode package.json package-lock.json ./
114+
RUN . /usr/local/share/nvm/nvm.sh && npm ci --ignore-scripts
115+
116+
WORKDIR /tmp/frontend
117+
COPY --chown=vscode:vscode apps/frontend/package.json apps/frontend/package-lock.json ./
118+
RUN . /usr/local/share/nvm/nvm.sh && npm ci --legacy-peer-deps --ignore-scripts
119+
120+
# Clean up temp directories
121+
USER root
122+
RUN rm -rf /tmp/backend /tmp/root /tmp/frontend
123+
124+
# Reset working directory
73125
WORKDIR /workspaces
74126

75127
# Default command

.devcontainer/post-create.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ echo "🚀 Setting up SimpleAccounts-UAE development environment..."
77

88
# Install root dependencies
99
echo "📦 Installing root npm dependencies..."
10-
npm install
10+
npm ci --prefer-offline
1111

1212
# Install frontend dependencies
1313
echo "📦 Installing frontend dependencies..."
1414
cd apps/frontend
15-
npm install --legacy-peer-deps
15+
npm ci --legacy-peer-deps --prefer-offline
1616
cd ../..
1717

1818
# Install Playwright browsers (using system Chromium)
1919
echo "🎭 Setting up Playwright..."
2020
cd apps/frontend
21-
npx playwright install-deps 2>/dev/null || true
21+
# npx playwright install-deps 2>/dev/null || true <-- Dependencies now in Dockerfile
2222
cd ../..
2323

2424
# Download Maven dependencies

0 commit comments

Comments
 (0)