diff --git a/Dockerfile b/Dockerfile index 31440967..a9c60d71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,24 @@ -FROM node:18 as builder +# syntax=docker/dockerfile:1 +FROM node:18 AS deps +ARG NODE_ENV=production WORKDIR /app +COPY ./package*.json ./ +RUN npm ci -COPY ./* ./ - -RUN npm install +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 run build -FROM node:18-alpine as runner - +FROM gcr.io/distroless/nodejs18-debian12:nonroot AS runner WORKDIR /app ENV NODE_ENV=production - -COPY --from=builder /app/dist/main.js ./dist COPY ./package.json ./ - -RUN npm install - -CMD ["node", "main.js"] +COPY --from=builder /app/dist/ ./dist/ +COPY --from=deps /app/node_modules/ ./node_modules/ +CMD ["dist/main.js"]