From a0e6797e40be042e836f03169e417a2ef0a5b094 Mon Sep 17 00:00:00 2001 From: Eric Thuaud <58465319+EricThuaud@users.noreply.github.com> Date: Fri, 17 May 2024 11:14:26 +0200 Subject: [PATCH] fix - rework dockerfile and nginx conf --- Dockerfile | 22 ++++++++++++++++++++-- nginx-frontmoog.conf => nginx.conf | 2 +- package.json | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) rename nginx-frontmoog.conf => nginx.conf (95%) diff --git a/Dockerfile b/Dockerfile index 4b1fabf..206c8d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,33 @@ FROM nginx:stable-alpine -COPY build /usr/share/nginx/html + +## Remove default nginx index page +RUN rm -rf /usr/share/nginx/html/* + +ADD build /usr/share/nginx/html + RUN rm etc/nginx/conf.d/default.conf -COPY nginx-frontmoog.conf etc/nginx/conf.d/ +COPY nginx.conf etc/nginx/conf.d/ # Copy .env file and shell script to container WORKDIR /usr/share/nginx/html + +# Add bash +RUN apk add --no-cache bash + COPY ./scripts/env.sh . COPY .env . # Make shell script executable RUN chmod +x env.sh +# add non-root user +RUN touch /var/run/nginx.pid +RUN chown -R nginx:nginx /var/run/nginx.pid /usr/share/nginx/html /var/cache/nginx /var/log/nginx /etc/nginx/conf.d + +# non root users cannot listen on 80 +EXPOSE 8080 + +USER nginx + # Start Nginx server CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""] diff --git a/nginx-frontmoog.conf b/nginx.conf similarity index 95% rename from nginx-frontmoog.conf rename to nginx.conf index 8313900..aa3c506 100644 --- a/nginx-frontmoog.conf +++ b/nginx.conf @@ -1,5 +1,5 @@ server { - listen 80 default_server; + listen 8080; server_name /usr/share/nginx/html; root /usr/share/nginx/html; diff --git a/package.json b/package.json index 56c6bee..c9110cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "front-moog", - "version": "2.2.5", + "version": "2.2.6", "private": true, "dependencies": { "@vtex/react-csv-parse": "^3.0.2",