-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (31 loc) · 813 Bytes
/
Dockerfile
File metadata and controls
38 lines (31 loc) · 813 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
# Stage 1: Build the React Client
FROM node:20-alpine AS client-builder
WORKDIR /app/Client
COPY Client/package*.json ./
RUN npm ci
COPY Client/ ./
RUN npm run build
# Stage 2: Build the Express Server
FROM node:20-alpine AS server-builder
WORKDIR /app/Server
COPY Server/package*.json ./
RUN npm ci
COPY Server/ ./
RUN npm run build
# Stage 3: Production Environment
FROM node:20-alpine
WORKDIR /app/Server
ENV NODE_ENV=production
# Copy Server files
COPY Server/package*.json ./
RUN npm ci --only=production
COPY --from=server-builder /app/Server/dist ./dist
# Copy Client build into Server's public directory
COPY --from=client-builder /app/Client/dist ./public
# Ensure uploads directory exists
RUN mkdir -p uploads
# Expose port
EXPOSE 8080
ENV PORT=8080
# Start server
CMD ["node", "dist/server.js"]