Docker setup

This commit is contained in:
Anna-Sara Sélea 2025-10-30 14:06:41 +01:00
parent 5bafdd180c
commit abb32911fe
4 changed files with 62 additions and 0 deletions

43
Dockerfile Normal file
View file

@ -0,0 +1,43 @@
# 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/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
# We need to make sure not to run the container as a non root user
# for better security
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;"]

19
nginx/nginx.conf Normal file
View file

@ -0,0 +1,19 @@
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /health {
return 200;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB