-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
34 lines (24 loc) · 918 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
33
34
# Step 1: Build the React app
# Use an official Node.js image as the base image
FROM node:18-alpine AS build
# Set the working directory in the container
WORKDIR /app
# Copy the package.json and package-lock.json (if available)
COPY package*.json ./
# Install dependencies
RUN npm install --silent
# Copy the rest of the application code to the working directory
COPY . .
# Build the React app
RUN npm run build
# Step 2: Serve the React app using an Nginx server
# Use an official Nginx image as the base image
FROM nginx:stable-alpine
# Copy the built React app from the previous step to the Nginx HTML folder
COPY --from=build /app/build /usr/share/nginx/html
# Update the Nginx configuration to listen on port 8080
RUN sed -i 's/listen 80;/listen 8080;/g' /etc/nginx/conf.d/default.conf
# Expose port 8080
EXPOSE 8080
# Start Nginx when the container starts
CMD ["nginx", "-g", "daemon off;"]