-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (20 loc) · 729 Bytes
/
Copy pathDockerfile
File metadata and controls
30 lines (20 loc) · 729 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
# Use the official Node.js 16 image as the base image
FROM node:16-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock) to the container
COPY package*.json ./
# Install project dependencies
RUN npm install
# Copy the rest of the application code to the container
COPY . .
# Build the React app
RUN npm run build
# second build stage with nginx
FROM nginx:1.21-alpine
# Copy the built React app from the previous stage
COPY --from=builder /app/build /usr/share/nginx/html
# Expose the port that the app will run on (usually 3000 by default)
EXPOSE 80
# Start the React app when the container starts
CMD [ "nginx", "-g", "daemon off;" ]