Skip to content

Commit aef7d25

Browse files
committed
refactor: reorganize production stage in Dockerfile for better clarity and structure
1 parent 773a213 commit aef7d25

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,26 @@ RUN npm run build
2727
# =============================================
2828
FROM node:24-alpine AS production
2929

30-
# Security: no root, no shell attack surface
31-
RUN addgroup -S app && adduser -S app -G app \
32-
&& apk --no-cache add tini \
30+
# Install build tools for native modules (better-sqlite3) and tini
31+
RUN apk --no-cache add \
32+
python3 \
33+
make \
34+
g++ \
35+
tini \
3336
&& rm -rf /var/cache/apk/*
3437

38+
# Security: no root, no shell attack surface
39+
RUN addgroup -S app && adduser -S app -G app
40+
3541
WORKDIR /app
3642

3743
# Copy only production artifacts
3844
COPY --from=build /app/dist ./dist
3945
COPY --from=build /app/package.json ./package.json
4046
COPY --from=build /app/package-lock.json ./package-lock.json
4147

42-
# Install ONLY production deps
43-
RUN npm ci --omit=dev --ignore-scripts \
48+
# Install ONLY production deps (build better-sqlite3 native module)
49+
RUN npm ci --omit=dev \
4450
&& npm cache clean --force \
4551
&& rm -rf /tmp/*
4652

0 commit comments

Comments
 (0)