Introduce a multi-stage Docker build and runtime image so the server can be built and launched consistently across environments, and document build/run usage in README.
25 lines
346 B
Docker
25 lines
346 B
Docker
FROM node:20-bookworm-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
COPY tsconfig.json ./
|
|
COPY src ./src
|
|
RUN npm run build
|
|
|
|
FROM node:20-bookworm-slim AS runtime
|
|
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
|
|
COPY package*.json ./
|
|
RUN npm ci --omit=dev
|
|
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["node", "dist/index.js"]
|