app/apps/backend/Dockerfile
Mathis b512732a14
Add Dockerfile for frontend and backend apps
Introduced Dockerfiles for both frontend and backend applications to set up production environments. The frontend Dockerfile configures Next.js and the backend Dockerfile configures a Nest.js setup, both using node:lts-alpine base images. This update streamlines dependencies installation and container runtime configurations.
2024-10-25 09:35:50 +02:00

22 lines
765 B
Docker

# Install dependencies only when needed
FROM docker.io/node:lts-alpine AS deps
# 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
WORKDIR /usr/src/app
COPY dist/apps/backend/package*.json ./
RUN npm install --omit=dev
# Production image, copy all the files and run nest
FROM docker.io/node:lts-alpine AS runner
RUN apk add --no-cache dumb-init
ENV NODE_ENV=production
ENV PORT=3000
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=deps /usr/src/app/package.json ./package.json
COPY dist/apps/backend .
RUN chown -R node:node .
USER node
EXPOSE 3000
CMD ["dumb-init", "node", "main.js"]