-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
41 lines (29 loc) · 1010 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
35
36
37
38
39
40
41
# Build Stage
FROM node:latest as build-stage
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application files to the working directory
COPY . .
# Build the React application
RUN npm run build
# Production Stage
FROM nginx:latest
# Copy the NGINX configuration file
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy the build artifacts from the build stage to NGINX web server
COPY --from=build-stage /app/build/ /usr/share/nginx/html
WORKDIR /app
RUN chown -R nginx:nginx /app && chmod -R 755 /app && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
chown -R nginx:nginx /etc/nginx/conf.d
RUN touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid
USER nginx
# Expose port 80 for the NGINX server
EXPOSE 80
# Command to start NGINX when the container is run
CMD ["nginx", "-g", "daemon off;"]