From 44af6b6ba0b1fef87cbd1c2ae7709b3b0e9fe04b Mon Sep 17 00:00:00 2001 From: Niall Thomson Date: Thu, 10 Oct 2024 14:09:40 -0600 Subject: [PATCH] chore: multi-stage build for checkout --- src/checkout/Dockerfile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/checkout/Dockerfile b/src/checkout/Dockerfile index f74f79ee5..2370a1538 100644 --- a/src/checkout/Dockerfile +++ b/src/checkout/Dockerfile @@ -1,3 +1,12 @@ +FROM node:20-alpine AS build +WORKDIR /usr/src/app +COPY --chown=node:node package*.json ./ +COPY --chown=node:node . . +RUN npm run build +RUN npm ci -f && npm cache clean --force +USER node + + FROM public.ecr.aws/amazonlinux/amazonlinux:2023 # We tell DNF not to install Recommends and Suggests packages, which are @@ -26,12 +35,7 @@ RUN useradd \ WORKDIR /app USER appuser -COPY --chown=appuser:appuser package.json . -COPY --chown=appuser:appuser package-lock.json . - -RUN npm ci - -ADD . /app -RUN npm run build +COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules +COPY --chown=node:node --from=build /usr/src/app/dist ./dist -ENTRYPOINT [ "node", "dist/main.js" ] +ENTRYPOINT [ "node", "dist/main.js" ] \ No newline at end of file