This repository has been archived on 2023-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
futureporn-qa/Dockerfile

50 lines
1.7 KiB
Docker

FROM node:18-alpine AS build
# Install dependencies only when needed
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN corepack enable && corepack prepare pnpm@latest --activate
# Enable `pnpm add --global` on Alpine Linux by setting
# home location environment variable to a location already in $PATH
# https://github.com/pnpm/pnpm/issues/784#issuecomment-1518582235
ENV PNPM_HOME=/usr/local/bin
WORKDIR /app
# Copy and install the dependencies for the project
COPY package.json pnpm-lock.yaml ./
# Copy all other project files to working directory
COPY . .
# Run the next build process and generate the artifacts
RUN pnpm i; pnpm run build
# we are using multi stage build process to keep the image size as small as possible
FROM node:18-alpine
# update and install latest dependencies, add dumb-init package
# add a non root user
RUN apk update && apk upgrade && apk add dumb-init ffmpeg && adduser -D qa
# set work dir as app
WORKDIR /app
# copy the public folder from the project as this is not included in the build process
COPY --from=build --chown=qa:qa /app/dist/ .
COPY --from=build --chown=qa:qa /app/package.json .
COPY --from=build --chown=qa:qa /app/node_modules ./node_modules
COPY --from=build --chown=qa:qa /app/Procfile .
COPY --from=build --chown=qa:qa /app/app.json .
# set non root user
USER qa
# expose 3000 on container
EXPOSE 3000
# set app host ,port and node env
ENV HOSTNAME=0.0.0.0 PORT=3000 NODE_ENV=production
# start the app with dumb init to spawn the Node.js runtime process
# with signal support
CMD [ "dumb-init", "node", "manager.js" ]