-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
31 lines (22 loc) · 713 Bytes
/
Dockerfile
File metadata and controls
31 lines (22 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Use Node.js 20 LTS as base image with latest security patches
FROM node:20-alpine
# Update Alpine packages for security patches
RUN apk update && apk upgrade
# Set working directory inside container
WORKDIR /app
# Copy package.json and package-lock.json first (for better caching)
COPY package*.json ./
# Install all dependencies (including dev dependencies for Babel)
RUN npm ci
# Copy application code
COPY . .
# Create a non-root user for security
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nodejs -u 1001
# Change ownership of the app directory to nodejs user
RUN chown -R nodejs:nodejs /app
USER nodejs
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD ["npm", "start"]