-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57e4bde
commit a60738c
Showing
1 changed file
with
19 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |