Created
October 8, 2023 17:50
-
-
Save damianobarbati/ecf573cbd71bcad5787b3f5cee88bafc to your computer and use it in GitHub Desktop.
Dockerfile with squash
This file contains hidden or 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
FROM node:20.6-alpine as build | |
ARG NODE_ENV | |
ENV NODE_ENV=$NODE_ENV | |
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | |
COPY ./ /opt | |
WORKDIR /opt | |
RUN apk --no-cache --update --upgrade add npm dumb-init | |
RUN npm install -g pnpm | |
# webapp dependencies and build | |
RUN pnpm install --filter webapp --prod=false --frozen-lockfile | |
RUN pnpm -F webapp build | |
# squash previous layers and reuse only artifacts | |
FROM node:20.6-alpine | |
ARG NODE_ENV | |
ENV NODE_ENV=$NODE_ENV | |
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | |
COPY ./ /opt | |
WORKDIR /opt | |
RUN apk --no-cache --update --upgrade add npm dumb-init | |
RUN npm install -g pnpm | |
# api dependencies | |
RUN pnpm install --filter api | |
RUN rm -rf /root/.local/ | |
# webapp artifacts | |
COPY --from=build --chown=node:node /opt/packages/webapp/dist /opt/packages/api/dist | |
USER node | |
CMD dumb-init pnpm -F api start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment