Skip to content

Commit

Permalink
Update Dockerfile (#11)
Browse files Browse the repository at this point in the history
Update Dockerfile

Reviewed-by: quintoin
Reviewed-by: Artem Lifshits
  • Loading branch information
vladimirvshivkov authored Aug 23, 2024
1 parent 5befb45 commit 6fc2d73
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# syntax=docker/dockerfile:1

FROM node:20
# Use an official Node.js runtime as the base image
FROM node:20-slim

ENV NODE_ENV production
# Set the environment to production
ENV NODE_ENV=production

# Set the working directory in the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
COPY package*.json ./

RUN npm ci --omit=dev
# Install production dependencies
RUN npm ci --only=production && \
npm cache clean --force

USER 1001
# Create a non-root user and switch to it
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nodeuser && \
chown -R nodeuser:nodejs /usr/src/app
USER nodeuser

COPY . .
# Copy the rest of the application code
COPY --chown=nodeuser:nodejs . .

# Expose the port the app runs on
EXPOSE 6000

0 comments on commit 6fc2d73

Please sign in to comment.