-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (35 loc) · 1.13 KB
/
Copy pathDockerfile
File metadata and controls
50 lines (35 loc) · 1.13 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
# Stage 1: Build Frontend and Backend
FROM node:20-alpine AS builder
WORKDIR /app
# --- Frontend Build ---
COPY package.json package-lock.json .npmrc ./
RUN npm ci
COPY . .
RUN npm run build
# --- Backend Build ---
WORKDIR /app/backend
RUN npm ci
RUN npm run build
# Stage 2: Production Image
FROM node:20-alpine
# Install Nginx and set up necessary directories and permissions
RUN apk add --no-cache nginx && \
mkdir -p /var/lib/nginx/tmp /var/log/nginx /run/nginx && \
chown -R node:node /var/lib/nginx /var/log/nginx /run/nginx && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
WORKDIR /app
# Copy built assets from the builder stage
COPY --from=builder /app/backend /app
COPY --from=builder /app/dist /app/frontend
# Create the data directory for volume mounting
RUN mkdir -p /app/data
# Copy Nginx config and startup script
COPY docker/nginx.conf /etc/nginx/nginx.conf
COPY docker/start.sh /app/start.sh
# Make the startup script executable and change ownership of all app files
RUN chmod +x /app/start.sh
RUN chown -R node:node /app
USER node
EXPOSE 3000
CMD ["/app/start.sh"]