From eeee00a2a5cd374f1bbc23f3cf5198c4d6f5e456 Mon Sep 17 00:00:00 2001 From: Mogyuchi Date: Mon, 23 Oct 2023 19:33:45 +0900 Subject: [PATCH] fix Dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - npm ci を使用するように変更。 - 記法統一 Co-authored-by: InkoHX --- Dockerfile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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"]