From 769d045c16ea3fbf89cff3baef975dbdc614f2f8 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 4 Jun 2025 12:18:43 +1000 Subject: [PATCH] Converting to multi-stage dockerfile --- Dockerfile | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index f5c491d4..5d7724d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,48 @@ -FROM node:22-slim +# Build stage +FROM node:24-slim AS builder # Set working directory WORKDIR /app -# Copy files -COPY . . +# Copy package files for installation +COPY package*.json ./ +COPY .npmrc ./ +COPY client/package*.json ./client/ +COPY server/package*.json ./server/ +COPY cli/package*.json ./cli/ # Install dependencies -# Working around https://github.com/npm/cli/issues/4828 -# RUN npm ci -RUN npm install --no-package-lock +RUN npm ci --ignore-scripts + +# Copy source files +COPY . . # Build the application RUN npm run build -ARG CLIENT_PORT=6274 -ARG SERVER_PORT=6277 +# Production stage +FROM node:24-slim -EXPOSE ${CLIENT_PORT} ${SERVER_PORT} +WORKDIR /app + +# Copy package files for production +COPY package*.json ./ +COPY .npmrc ./ +COPY client/package*.json ./client/ +COPY server/package*.json ./server/ +COPY cli/package*.json ./cli/ + +# Install only production dependencies +RUN npm ci --omit=dev --ignore-scripts + +# Copy built files from builder stage +COPY --from=builder /app/client/dist ./client/dist +COPY --from=builder /app/client/bin ./client/bin +COPY --from=builder /app/server/build ./server/build +COPY --from=builder /app/cli/build ./cli/build + +# Document which ports the application uses internally +EXPOSE 6274 6277 # Use ENTRYPOINT with CMD for arguments -ENTRYPOINT ["npm", "start"] -CMD [] \ No newline at end of file +ENTRYPOINT ["npm", "start"] \ No newline at end of file