diff --git a/Dockerfile b/Dockerfile index 012c57e8..a9c60d71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,23 +3,22 @@ FROM node:18 AS deps ARG NODE_ENV=production WORKDIR /app -COPY ./package*.json . -RUN npm install +COPY ./package*.json ./ +RUN npm ci -FROM deps AS builder +FROM node:18 AS builder ARG NODE_ENV=development WORKDIR /app +COPY ./build.js ./ +COPY ./package*.json ./ +RUN npm ci COPY ./src/ ./src/ -RUN npm install -RUN --mount=type=bind,source=build.js,target=build.js \ - npm run build +RUN npm run build FROM gcr.io/distroless/nodejs18-debian12:nonroot AS runner WORKDIR /app ENV NODE_ENV=production - -COPY --from=builder /app/dist/ ./dist/ COPY ./package.json ./ +COPY --from=builder /app/dist/ ./dist/ COPY --from=deps /app/node_modules/ ./node_modules/ - CMD ["dist/main.js"]