diff --git a/Dockerfile b/Dockerfile index c4fd495..e41e48f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,39 @@ # build environment -FROM node:14.17.5-alpine as build +FROM node:14.19.0-alpine3.15 as build WORKDIR /app ENV PATH /app/node_modules/.bin:$PATH COPY package.json /app/package.json -RUN apk add --no-cache git -RUN npm install --production -COPY . /app +RUN apk update && apk upgrade && \ + apk add --no-cache bash git openssh -# set baseurl to get connected with backend API -ARG SERVER_URL=http://localhost:9000/ +# Install dependencies with legacy peer deps +RUN npm install --silent --legacy-peer-deps -ENV REACT_APP_SERVER_URL=$SERVER_URL +COPY . /app RUN npm run build --if-present # host environment -FROM nginx:1.16.0-alpine +FROM nginx:1.25.1-alpine + +# Update and upgrade Alpine packages +RUN apk update && apk upgrade + COPY --from=build /app/build /usr/share/nginx/html RUN rm /etc/nginx/conf.d/default.conf -COPY nginx/nginx.conf /etc/nginx/conf.d -EXPOSE 80 +COPY nginx/nginx.conf /etc/nginx/nginx.conf + +# Create necessary directories and set permissions +RUN mkdir -p /tmp/nginx /var/cache/nginx /var/run /var/log/nginx && \ + chown -R 10014:10014 /tmp/nginx /var/cache/nginx /var/run /var/log/nginx /usr/share/nginx/html && \ + chmod -R 755 /tmp/nginx /var/cache/nginx /var/run /var/log/nginx /usr/share/nginx/html + +# Create a non-root user +RUN adduser -D -u 10014 choreouser + +# Switch to the non-root user +USER 10014 + +EXPOSE 8080 + CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 758a646..e48ac73 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,17 +1,37 @@ -server { +worker_processes auto; +error_log /dev/stdout info; +pid /tmp/nginx.pid; - listen 80; +events { + worker_connections 1024; +} - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html; - } +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; - error_page 500 502 503 504 /50x.html; + access_log /dev/stdout; + server_tokens off; - location = /50x.html { - root /usr/share/nginx/html; - } + client_body_temp_path /tmp/client_temp; + proxy_temp_path /tmp/proxy_temp_path; + fastcgi_temp_path /tmp/fastcgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + scgi_temp_path /tmp/scgi_temp; + server { + listen 8080; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + + location = /50x.html { + root /usr/share/nginx/html; + } + } } \ No newline at end of file diff --git a/package.json b/package.json index c2dcec5..2ca1038 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,16 @@ "react-scripts": "^5.0.0", "react-spinners": "^0.11.0", "three-spritetext": "^1.6.5", - "web-vitals": "^2.1.4" + "web-vitals": "^2.1.4", + "ajv": "^6.12.6", + "ajv-keywords": "^3.5.2", + "@babel/core": "^7.16.0", + "@babel/preset-env": "^7.16.0", + "@babel/preset-react": "^7.16.0", + "babel-loader": "^8.2.3" + }, + "devDependencies": { + "react-scripts": "^5.0.0" }, "scripts": { "start": "react-scripts start", diff --git a/public/index.html b/public/index.html index 5e821f1..8d54138 100644 --- a/public/index.html +++ b/public/index.html @@ -3,6 +3,8 @@
+ +