-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (27 loc) · 848 Bytes
/
Dockerfile
File metadata and controls
38 lines (27 loc) · 848 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
32
33
34
35
36
37
38
# Use official Node.js runtime as base image
FROM node:18-alpine
# Set working directory in container
WORKDIR /app
# Copy package.json and package-lock.json (if available)
COPY package*.json ./
# Install all dependencies (including devDependencies for build)
RUN npm ci
# Copy application source code
COPY . .
# Build TypeScript application
RUN npm run build
# Remove devDependencies to reduce image size
RUN npm prune --production
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs
RUN adduser -S appserver -u 1001
# Change ownership of app directory
RUN chown -R appserver:nodejs /app
USER appserver
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# Start the application
CMD ["node", "out/index.js"]