-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (45 loc) · 1.38 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (45 loc) · 1.38 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Build stage for frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (including devDependencies for build)
RUN npm ci
# Copy source files
COPY . .
# Build the frontend
RUN npm run build
# Production stage for backend
FROM node:20-alpine AS backend
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install only production dependencies
RUN npm ci --omit=dev
# Copy backend server
COPY server.js ./
# Expose backend port
EXPOSE 3000
CMD ["node", "server.js"]
# Production stage with nginx for frontend + backend
FROM nginx:alpine AS production
# Install Node.js, curl (for health checks), and openssl for certificate generation
RUN apk add --no-cache nodejs npm curl openssl
WORKDIR /app
# Generate self-signed SSL certificate
RUN mkdir -p /etc/nginx/ssl && \
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/nginx/ssl/key.pem \
-out /etc/nginx/ssl/cert.pem \
-subj "/C=US/ST=State/L=City/O=InReader/CN=localhost"
# Copy nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Copy built frontend files
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
# Copy backend
COPY --from=backend /app /app/backend
# Copy startup script
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
EXPOSE 80
ENTRYPOINT ["/docker-entrypoint.sh"]