Converting to multi-stage dockerfile
This commit is contained in:
parent
ef6d84933a
commit
769d045c16
1 changed files with 35 additions and 11 deletions
46
Dockerfile
46
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 []
|
||||
ENTRYPOINT ["npm", "start"]
|
||||
Loading…
Reference in a new issue