Created
February 20, 2023 20:26
-
-
Save nikosson/854f2cbbe4a78c3b40019f74bc78a78a to your computer and use it in GitHub Desktop.
Dockerfile nodejs alpine with puppeteer support
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
| ARG NODE_VERSION='16.13.1-alpine' | |
| # base | |
| FROM node:${NODE_VERSION} as base | |
| ENV HUSKY_SKIP_INSTALL 1 | |
| ENV DISABLE_OPENCOLLECTIVE 1 | |
| ENV SUPPRESS_SUPPORT 1 | |
| ENV NODE_ENV CI | |
| WORKDIR /build | |
| ARG DOCKER_DIR | |
| COPY package*.json ./ | |
| COPY ../../prisma ./prisma/ | |
| RUN npm ci | |
| COPY ../.. ./ | |
| # audit | |
| FROM base as audit | |
| RUN npm audit --json --audit-level=critical | |
| # tests | |
| FROM base as tests | |
| RUN npm run test:cov | |
| # build | |
| FROM base as build | |
| RUN npm run build | |
| # main | |
| FROM node:${NODE_VERSION} | |
| RUN apk update && apk add --no-cache nmap && \ | |
| echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \ | |
| echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \ | |
| apk update && \ | |
| apk add --no-cache \ | |
| chromium \ | |
| harfbuzz \ | |
| "freetype>2.8" \ | |
| ttf-freefont \ | |
| nss | |
| ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true | |
| ENV DISABLE_OPENCOLLECTIVE 1 | |
| ENV SUPPRESS_SUPPORT 1 | |
| ENV NODE_ENV production | |
| WORKDIR /app | |
| COPY package*.json ./ | |
| COPY ../../prisma ./prisma/ | |
| RUN npm ci | |
| ARG GIT_VERSION | |
| ENV GIT_COMMIT ${GIT_VERSION} | |
| COPY --from=tests /build/coverage /app/tests/coverage | |
| COPY --from=build /build/dist /app/dist | |
| ENTRYPOINT ["npm", "run", "start:migrate:prod"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment