Skip to content

Commit 769d045

Browse files
committed
Converting to multi-stage dockerfile
1 parent ef6d849 commit 769d045

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

Dockerfile

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,48 @@
1-
FROM node:22-slim
1+
# Build stage
2+
FROM node:24-slim AS builder
23

34
# Set working directory
45
WORKDIR /app
56

6-
# Copy files
7-
COPY . .
7+
# Copy package files for installation
8+
COPY package*.json ./
9+
COPY .npmrc ./
10+
COPY client/package*.json ./client/
11+
COPY server/package*.json ./server/
12+
COPY cli/package*.json ./cli/
813

914
# Install dependencies
10-
# Working around https://github.com/npm/cli/issues/4828
11-
# RUN npm ci
12-
RUN npm install --no-package-lock
15+
RUN npm ci --ignore-scripts
16+
17+
# Copy source files
18+
COPY . .
1319

1420
# Build the application
1521
RUN npm run build
1622

17-
ARG CLIENT_PORT=6274
18-
ARG SERVER_PORT=6277
23+
# Production stage
24+
FROM node:24-slim
25+
26+
WORKDIR /app
27+
28+
# Copy package files for production
29+
COPY package*.json ./
30+
COPY .npmrc ./
31+
COPY client/package*.json ./client/
32+
COPY server/package*.json ./server/
33+
COPY cli/package*.json ./cli/
34+
35+
# Install only production dependencies
36+
RUN npm ci --omit=dev --ignore-scripts
37+
38+
# Copy built files from builder stage
39+
COPY --from=builder /app/client/dist ./client/dist
40+
COPY --from=builder /app/client/bin ./client/bin
41+
COPY --from=builder /app/server/build ./server/build
42+
COPY --from=builder /app/cli/build ./cli/build
1943

20-
EXPOSE ${CLIENT_PORT} ${SERVER_PORT}
44+
# Document which ports the application uses internally
45+
EXPOSE 6274 6277
2146

2247
# Use ENTRYPOINT with CMD for arguments
23-
ENTRYPOINT ["npm", "start"]
24-
CMD []
48+
ENTRYPOINT ["npm", "start"]

0 commit comments

Comments
 (0)