forked from phu1110/motel-room
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 700 Bytes
/
Dockerfile
File metadata and controls
39 lines (27 loc) · 700 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
39
# Multi-stage build
FROM node:18-alpine AS builder
WORKDIR /app
# Accept build args
ARG REACT_APP_API_URL
ARG REACT_APP_API
# Set environment variables for build
ENV REACT_APP_API_URL=$REACT_APP_API_URL
ENV REACT_APP_API=$REACT_APP_API
# Copy package files
COPY package*.json ./
RUN npm ci --only=production
# Copy source code
COPY . .
# Build React app
RUN npm run build
# Production stage - chỉ cần serve static files
FROM node:18-alpine
WORKDIR /app
# Install serve package globally
RUN npm install -g serve
# Copy build folder từ builder stage
COPY --from=builder /app/build ./build
# Expose port 3000
EXPOSE 3001
# Start serve command
CMD ["serve", "-s", "build", "-l", "3001"]