Skip to content

Commit ea84149

Browse files
committed
Fix docker file
1 parent 661df12 commit ea84149

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

Dockerfile

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
1-
# Dependencies
2-
FROM node:22-alpine AS dependencies
1+
# 1. Dependencies for building
2+
FROM node:22-bookworm-slim AS build-deps
33
WORKDIR /app
44
COPY package.json package-lock.json ./
5-
RUN npm install
5+
RUN npm ci
66

7-
# Build
8-
FROM node:22-alpine AS build
7+
# 2. Build the application
8+
FROM node:22-bookworm-slim AS build
99
WORKDIR /app
10-
COPY --from=dependencies /app/node_modules ./node_modules
10+
COPY --from=build-deps /app/node_modules ./node_modules
1111
COPY . .
1212
RUN npm run build
1313

14-
# Deploy
15-
FROM node:22-alpine as deploy
14+
# 3. Dependencies for production ONLY
15+
FROM node:22-bookworm-slim AS prod-deps
1616
WORKDIR /app
17-
ENV NODE_ENV production
18-
EXPOSE 3000
17+
COPY package.json package-lock.json ./
18+
RUN npm ci --omit=dev
19+
20+
# 4. Deploy
21+
FROM node:22-bookworm-slim AS deploy
22+
WORKDIR /app
23+
24+
# Set to production environment
25+
ENV NODE_ENV=production
26+
27+
# Copy only what is strictly necessary for runtime
1928
COPY --from=build /app/package.json ./
20-
COPY --from=build /app/node_modules ./node_modules
29+
COPY --from=prod-deps /app/node_modules ./node_modules
2130
COPY --from=build /app/dist ./dist
22-
CMD [ "npm", "run", "start" ]
31+
32+
RUN mkdir logs && chown node:node logs
33+
34+
USER node
35+
36+
EXPOSE 3000
37+
38+
# Run node directly for proper signal handling (graceful shutdowns)
39+
# Make sure to point this to your actual compiled entry file!
40+
CMD [ "node", "dist/index.js" ]

0 commit comments

Comments
 (0)