diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..f58ba9f --- /dev/null +++ b/.env.development @@ -0,0 +1,30 @@ +SKIP_PREFLIGHT_CHECK=true + +REACT_APP_FACEBOOK="https://www.facebook.com/profile.php?id=100066498622246" +REACT_APP_TWITTER="https://twitter.com/fluxtra" + +REACT_APP_APPSITE="https://myfitapp.mermsemr.com" +#REACT_APP_APPSITE="http://localhost:7012" + + +# REACT_APP_AUX_ENDPOINT="http://10.20.30.32:9083/svs/user" +# REACT_APP_USERS_ENDPOINT="http://10.20.30.32:9083/svs/user" +REACT_APP_AUX_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/svs/user" +REACT_APP_USERS_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/svs/user" + +#REACT_APP_AUX_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/en/wrench/api/v1" +#REACT_APP_USERS_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/en/wrench/api/v1" + +#"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser" + +REACT_APP_SESSION_EXPIRE_MINUTES=300000 +REACT_APP_SESSION_EXPIRE_CHECKER=60000 + +REACT_APP_LOGIN_ERROR_TIMEOUT=7000 +REACT_APP_SIGNUP_ERROR_TIMEOUT=7000 + +# Had to change the error time to 3sec cause it took too long +REACT_APP_RESET_START_ERROR_TIMEOUT=3000 + +#apigate.lotus.g1.wrenchboard.com:76.209.103.227 +#apigate.orion.g1.wrenchboard.com:76.209.103.227 diff --git a/.env.poduction b/.env.poduction new file mode 100644 index 0000000..2dc4744 --- /dev/null +++ b/.env.poduction @@ -0,0 +1,30 @@ +SKIP_PREFLIGHT_CHECK=true + +REACT_APP_FACEBOOK="https://www.facebook.com/profile.php?id=100066498622246" +REACT_APP_TWITTER="https://twitter.com/fluxtra" + +REACT_APP_APPSITE="https://myfitapp.mermsemr.com" +#REACT_APP_APPSITE="http://localhost:7012" + + +# REACT_APP_AUX_ENDPOINT="http://10.20.30.32:9083/svs/user" +# REACT_APP_USERS_ENDPOINT="http://10.20.30.32:9083/svs/user" +REACT_APP_AUX_ENDPOINT="https://apigate.orion.g1.wrenchboard.com/svs/user" +REACT_APP_USERS_ENDPOINT="https://apigate.orion.g1.wrenchboard.com/svs/user" + +#REACT_APP_AUX_ENDPOINT="https://apigate.orion.g1.wrenchboard.com/en/wrench/api/v1" +#REACT_APP_USERS_ENDPOINT="https://apigate.orion.g1.wrenchboard.com/en/wrench/api/v1" + +#"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser" + +REACT_APP_SESSION_EXPIRE_MINUTES=300000 +REACT_APP_SESSION_EXPIRE_CHECKER=60000 + +REACT_APP_LOGIN_ERROR_TIMEOUT=7000 +REACT_APP_SIGNUP_ERROR_TIMEOUT=7000 + +# Had to change the error time to 3sec cause it took too long +REACT_APP_RESET_START_ERROR_TIMEOUT=3000 + +#apigate.orion.g1.wrenchboard.com:76.209.103.227 +#apigate.orion.g1.wrenchboard.com:76.209.103.227 diff --git a/docker-compose.yml b/docker-compose.yml index eace1a6..0d38e2c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,8 @@ services: build: context: . dockerfile: docker/Dockerfile + args: + - NODE_ENV=production restart: unless-stopped ports: - 9082:3000 @@ -20,12 +22,14 @@ services: - backend.wrenchboard.api.live:10.10.33.15 - backend.wrenchboard.api.test:10.10.33.15 - apigate.lotus.g1.wrenchboard.com:10.10.33.15 + - apigate.orion.g1.wrenchboard.com:10.10.33.15 # #- backend.wrenchboard.api.live:172.31.4.27 # #- backend.wrenchboard.api.test:10.20.30.27 - apigateway.wrenchboard.app.dev.fluxtra.net:10.20.30.19 - apigateway.wrenchboard.app.lotus.fluxtra.net:172.31.4.19 environment: - CHOKIDAR_USEPOLLING=true + - NODE_ENV=${NODE_ENV:-production} # volumes: # - ./:/app # - /app/node_modules diff --git a/docker/Dockerfile b/docker/Dockerfile index 95cd1df..ce4d1bb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,7 +3,15 @@ FROM alpine:3.15 +# Build args +ARG NODE_ENV + ENV NODE_VERSION 14.19.0 +ENV NODE_ENV=$NODE_ENV + +# install nginx +RUN apk update +RUN apk add nginx RUN addgroup -g 1000 node \ && adduser -u 1000 -G node -s /bin/sh -D node \ @@ -103,6 +111,10 @@ WORKDIR /usr/src/app # ENV PATH /app/node_modules/.bin:$PATH ENV PATH /usr/src/app/node_modules/.bin:$PATH +COPY nginx.conf ./ + +COPY run.sh ./ + # install app dependencies COPY package.json ./ RUN npm install @@ -114,7 +126,9 @@ RUN npm install COPY . ./ # start app -CMD ["npm","run", "start"] +# CMD ["npm","run", "start"] # CMD ["yarn", "start"] +# start app +CMD /bin/sh ./run.sh diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..b9f717a --- /dev/null +++ b/nginx.conf @@ -0,0 +1,29 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + server { + gzip on; + listen 3000; + server_name localhost; + root /usr/src/app/build; + + include /etc/nginx/mime.types; + + location /nginx_status { + stub_status on; + access_log off; + } + + location / { + try_files $uri $uri/ /index.html; + } + } +} + diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..a346abc --- /dev/null +++ b/run.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env sh +set -e +set -x + +export NODE_ENV="${NODE_ENV:-development}" + +if [ $NODE_ENV == "development" ]; then + # this runs webpack-dev-server with hot reloading + npm start +else + # build the app and serve it via nginx + npm run build + nginx -g 'daemon off;' -c /usr/src/app/nginx.conf + nginx -c /usr/src/app/nginx.conf +fi \ No newline at end of file