Skip to content

Commit

Permalink
chore: multi-stage build for checkout (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
niallthomson authored Oct 10, 2024
1 parent b7b8979 commit ca70de6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/checkout/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
FROM node:20-alpine AS build
WORKDIR /usr/src/app
COPY --chown=node:node package*.json ./
COPY --chown=node:node . .
RUN npm ci -f
RUN npm run build
USER node


FROM public.ecr.aws/amazonlinux/amazonlinux:2023

# We tell DNF not to install Recommends and Suggests packages, which are
# weak dependencies in DNF terminology, thus keeping our installed set of
# packages as minimal as possible.
RUN dnf --setopt=install_weak_deps=False install -q -y \
nodejs20 \
npm \
shadow-utils \
&& \
dnf clean all
Expand All @@ -26,12 +34,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" ]

0 comments on commit ca70de6

Please sign in to comment.