-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (36 loc) · 1.02 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (36 loc) · 1.02 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Build stage
FROM node:20-alpine3.18 AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies for build
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node:20-alpine3.18
# Create app user and group for security
RUN addgroup app && adduser -S -G app app
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy built application from builder stage
COPY --from=builder /app/dist ./dist
# Copy docs for Swagger
COPY --from=builder /app/docs ./docs
# Copy public assets (images, etc.)
COPY --from=builder /app/public ./public
# Copy any other necessary files
COPY --from=builder /app/package.json ./package.json
# Create logs directory with proper permissions BEFORE switching to app user
USER root
RUN mkdir -p /app/logs && chown -R app:app /app/logs
USER app
# Expose the port for the backend server
EXPOSE 4013
# Default command (production)
CMD ["npm", "start"]