Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's confirm the port that support scale to zero


CMD ["nginx", "-g", "daemon off;"]
42 changes: 31 additions & 11 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<script src="%PUBLIC_URL%/config.js"></script>

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<meta
Expand Down
4 changes: 3 additions & 1 deletion src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const {createProxyMiddleware} = require('http-proxy-middleware');
const API_URL = window?.configs?.serviceURL ? window.configs.serviceURL : "/";


module.exports = function (app) {
app.use(createProxyMiddleware('/images', {target: process.env.REACT_APP_SERVER_URL, changeOrigin: true}));
app.use(createProxyMiddleware('/images', {target: API_URL, changeOrigin: true}));
};