Skip to content

Commit 163a60c

Browse files
authored
feat: Update docker file (#1225)
### Summary The previous Alpine-based image was unreliable for some IDE dev containers. This change moves to Debian Bookworm slim, adds ca-certificates so install-idl (git over HTTPS) works inside the image, and defers npm to after the container starts so a failed install no longer blocks the dev container from coming up. Image size may grow slightly, though still in acceptable range. ### Changes - Dev containers / IDE compatibility: Base image and layout adjusted so dev containers work consistently across environments that struggled with the old image. - ca-certificates + git: Installed via apt-get so TLS verification succeeds when install-idl runs in-container. - Dev stage: No longer runs npm ci / dependency install as part of the image build; npm can be run after start, avoiding failed installs blocking container startup. - Build: Removed the extra npm run build step before build-standalone (standalone path is sufficient). - Docker ENV: Updated to the modern ENV KEY=value form to clear the old ENV format warning. ### Testing - Open the repo in a dev container in the IDEs that previously failed; confirm the container starts even before npm install / npm ci. - Check size change: <img width="753" height="105" alt="Screenshot 2026-03-27 at 17 30 30" src="https://github.com/user-attachments/assets/bd00f726-f096-48d3-a043-9192437a7150" /> - After start, run npm ci (or your usual install) and confirm npm run install-idl completes without TLS/git errors. - Docker build default/production target and smoke-test the running app. - Confirm Docker build logs no longer show the ENV deprecation/warning (screenshot for old warning): <img width="897" height="110" alt="Screenshot 2026-03-27 at 18 47 19" src="https://github.com/user-attachments/assets/6c61e085-50b1-4f69-a3b1-4fe3b17e27f2" />
1 parent 55bb328 commit 163a60c

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

Dockerfile

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,41 @@
1-
FROM node:18-alpine AS base
2-
3-
RUN apk update
4-
RUN apk --no-cache add git
5-
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
6-
RUN apk add --no-cache libc6-compat
7-
8-
# Install dependencies only when needed
9-
FROM base AS deps
10-
WORKDIR /app
11-
12-
# Install dependencies based on the preferred package manager
13-
COPY package.json package-lock.json ./
14-
RUN npm ci
15-
RUN npm run install-idl
16-
17-
1+
FROM node:18-bookworm-slim AS base
182

193
FROM base AS dev
20-
4+
# Install git + CA bundle so git https can verify TLS
5+
RUN apt-get update \
6+
&& apt-get install -y --no-install-recommends git ca-certificates \
7+
&& rm -rf /var/lib/apt/lists/*
218
WORKDIR /app
22-
COPY --from=deps /app/node_modules ./node_modules
239
COPY . .
2410

2511

26-
2712
# Rebuild the source code only when needed
2813
FROM base AS builder
2914
WORKDIR /app
30-
COPY --from=deps /app/node_modules ./node_modules
15+
RUN apt-get update \
16+
&& apt-get install -y --no-install-recommends git ca-certificates \
17+
&& rm -rf /var/lib/apt/lists/*
18+
COPY package.json package-lock.json ./
19+
RUN npm ci
20+
RUN npm run install-idl
3121
COPY . .
3222

33-
# Next.js collects completely anonymous telemetry data about general usage.
23+
# Disable Next.js telemetry from collecting general usage data.
3424
# Learn more here: https://nextjs.org/telemetry
35-
# Uncomment the following line in case you want to disable telemetry during the build.
36-
ENV NEXT_TELEMETRY_DISABLED 1
37-
# optimize Build size by including only required resources
25+
ENV NEXT_TELEMETRY_DISABLED=1
26+
3827

3928
RUN npm run generate:idl
40-
RUN npm run build
4129
RUN npm run build-standalone
4230
RUN npm run post-build-standalone
4331

44-
# Production image, copy all the files and run next
32+
# Production image, copy necessary files and run next
4533
FROM base AS runner
4634
WORKDIR /app
4735

48-
ENV NODE_ENV production
36+
ENV NODE_ENV=production
4937
# Uncomment the following line in case you want to disable telemetry during runtime.
50-
ENV NEXT_TELEMETRY_DISABLED 1
38+
ENV NEXT_TELEMETRY_DISABLED=1
5139

5240
RUN addgroup --system --gid 1001 nodejs
5341
RUN adduser --system --uid 1001 nextjs
@@ -61,7 +49,7 @@ RUN chown nextjs:nodejs .next
6149

6250
# Automatically leverage output traces to reduce image size
6351
# https://nextjs.org/docs/advanced-features/output-file-tracing
64-
COPY --from=builder --chown=nextjs:nodejs /app/src/__generated__/ ./src/__generated__/
52+
COPY --from=builder --chown=nextjs:nodejs /app/src/__generated__/ ./src/__generated__/
6553
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
6654
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
6755

0 commit comments

Comments
 (0)