Skip to content

Commit

Permalink
Implement multi-stage build in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
valtterikantanen committed Nov 18, 2024
1 parent 0356adc commit 47de3c4
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal AS build

ENV TZ="Europe/Helsinki"

WORKDIR /opt/app-root/src

# Setup
COPY package* ./
COPY package*.json ./
COPY tsconfig.json ./
RUN npm ci -f --omit-dev --ignore-scripts

RUN npm ci

COPY src ./src

# Build
RUN npm run build


FROM registry.access.redhat.com/ubi9/nodejs-18-minimal

ENV TZ="Europe/Helsinki"

ENV NODE_ENV=production

WORKDIR /opt/app-root/src

COPY --from=build /opt/app-root/src/package*.json ./
COPY --from=build /opt/app-root/src/build ./build

RUN npm ci

EXPOSE 3003

CMD ["npm", "run", "start:prod"]
CMD ["node", "build/index.js"]

0 comments on commit 47de3c4

Please sign in to comment.