-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
32 lines (22 loc) · 816 Bytes
/
Dockerfile
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
# Stage 1: Build the React application using Node.js 20.14.0
FROM node:20.14.0-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to install dependencies
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application files
COPY . .
# Build the React application for production
RUN npm run build
# Debugging: List contents of the /app/dist directory to ensure it exists
RUN ls -la /app/dist
# Stage 2: Serve the React build with Nginx
FROM nginx:alpine
# Copy the built React app from the builder stage (change 'build' to 'dist')
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose port 80 for serving the application
EXPOSE 80
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]