1
- # Use a specific version of nginx for better reproducibility
2
- FROM nginx:1.25.3- alpine
1
+ # Serve the app with NGINX
2
+ FROM nginx:alpine
3
3
4
- # Add a non-root user for security
5
- RUN adduser -D -H -u 1001 nginxuser && \
6
- chown -R nginxuser:nginxuser /usr/share/nginx/html && \
7
- chown -R nginxuser:nginxuser /var/cache/nginx && \
8
- touch /var/run/nginx.pid && \
9
- chown -R nginxuser:nginxuser /var/run/nginx.pid
4
+ # Copy the build files from the build folder to /usr/share/nginx/html
5
+ COPY build /usr/share/nginx/html
10
6
11
- # Copy files with specific ownership
12
- COPY --chown=nginxuser:nginxuser build /usr/share/nginx/html
13
- COPY --chown=nginxuser:nginxuser nginx.conf /etc/nginx/conf.d/default.conf
7
+ # Replace default nginx.conf with custom configuration
8
+ COPY nginx.conf /etc/nginx/conf.d/default.conf
14
9
15
- # Set working directory
16
- WORKDIR /usr/share/nginx/html
17
-
18
- # Switch to non-root user
19
- USER nginxuser
20
-
21
- # Expose port
10
+ # Expose the desired port (default is 80 for NGINX)
22
11
EXPOSE 80
23
12
24
- # Use exec form of CMD for better signal handling
25
- CMD ["nginx" , "-g" , "daemon off;" ]
26
-
27
- # Add healthcheck
28
- HEALTHCHECK --interval=30s --timeout=3s \
29
- CMD wget --quiet --tries=1 --spider http://localhost:80/ || exit 1
13
+ # Start NGINX
14
+ CMD ["nginx" , "-g" , "daemon off;" ]
0 commit comments