Skip to content

Commit 7c296e9

Browse files
committed
multi-stage docker build
1 parent 61f23e4 commit 7c296e9

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

template/Dockerfile

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
FROM node:22-alpine
2-
3-
ENV NODE_ENV=production
1+
FROM node:22 as build
42

5-
RUN mkdir /app
63
WORKDIR /app
74

85
COPY package*.json ./
96

10-
RUN npm install --production --legacy-peer-deps
7+
RUN npm ci --legacy-peer-deps
118

129
COPY . .
1310

11+
# Build
12+
RUN npm run build
13+
14+
# -------------------
15+
FROM node:22-alpine
16+
17+
WORKDIR /app
18+
19+
ENV NODE_ENV=production
20+
21+
# Copy source
22+
COPY . .
23+
24+
# Copy built files
25+
COPY --from=build /app/dist .
26+
27+
# Build and cleanup
28+
ENV NODE_ENV=production
29+
RUN npm ci --omit=dev --legacy-peer-deps
30+
31+
# Start server
1432
CMD ["node", "node_modules/moleculer/bin/moleculer-runner.js"]

0 commit comments

Comments
 (0)