Skip to content

Commit

Permalink
upgrade dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvdkolk committed Jul 12, 2024
1 parent 57e4bde commit a60738c
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
FROM node:20.10.0-alpine AS base

FROM base AS install-stage
WORKDIR /app

ENV YARN_VERSION=4.1.1
RUN apk add --no-cache libc6-compat

RUN corepack enable && corepack prepare yarn@${YARN_VERSION}

FROM base AS build
ENV NODE_ENV production
COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn ./.yarn
RUN yarn install --immutable
RUN yarn install --immutable && yarn cache clean

COPY --chown=node:node . .

FROM base AS build-stage
WORKDIR /app
COPY --from=install-stage /app/node_modules ./node_modules
COPY . .
RUN yarn build

USER node

FROM base AS production-stage
WORKDIR /app
COPY --from=build-stage /app/dist ./dist
COPY --from=install-stage /app/node_modules ./node_modules
COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn ./.yarn
ENV NODE_ENV production
COPY --chown=node:node --from=build /app/dist dist
COPY --chown=node:node --from=build /app/node_modules node_modules
COPY --chown=node:node --from=build /app/package.json package.json

USER node
CMD ["yarn", "start"]

0 comments on commit a60738c

Please sign in to comment.