-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Dockerfile Reviewed-by: quintoin Reviewed-by: Artem Lifshits
- Loading branch information
1 parent
5befb45
commit 6fc2d73
Showing
1 changed file
with
17 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
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 |