diff --git a/.env b/.env index 954b800..61db350 100644 --- a/.env +++ b/.env @@ -1,8 +1,5 @@ -REACT_APP_TUITIO_URL=http://localhost:5063 -# REACT_APP_TUITIO_URL=https://lab.code-rove.com/tuitio - -REACT_APP_NETWORK_RESURRECTOR_API_URL=http://localhost:5064 -#REACT_APP_NETWORK_RESURRECTOR_API_URL=https://lab.code-rove.com/network-resurrector-api +REACT_APP_TUITIO_URL=http://####### +REACT_APP_NETWORK_RESURRECTOR_API_URL=http://####### #600000 milliseconds = 10 minutes REACT_APP_MACHINE_PING_INTERVAL=600000 diff --git a/.env.production b/.env.production index e1901a4..5f0409f 100644 --- a/.env.production +++ b/.env.production @@ -1,6 +1,6 @@ -PUBLIC_URL=/network-resurrector/ -REACT_APP_TUITIO_URL=https://lab.code-rove.com/tuitio -REACT_APP_NETWORK_RESURRECTOR_API_URL=https://lab.code-rove.com/network-resurrector-api +PUBLIC_URL= +REACT_APP_TUITIO_URL=https://####### +REACT_APP_NETWORK_RESURRECTOR_API_URL=https://####### #900000 milliseconds = 15 minutes REACT_APP_MACHINE_PING_INTERVAL=900000 diff --git a/.gitignore b/.gitignore index 80f4a8c..a627bb5 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ # misc .DS_Store .env.local +.env.development .env.development.local .env.test.local .env.production.local diff --git a/dockerfile b/dockerfile index 14523a5..142e57e 100644 --- a/dockerfile +++ b/dockerfile @@ -2,22 +2,31 @@ FROM node:14-slim as builder WORKDIR /app +# global args +ARG APP_SUBFOLDER= + COPY .npmrc .npmrc COPY package*.json ./ RUN npm install RUN rm -f .npmrc COPY . ./ -RUN npm run build + +# set the PUBLIC_URL environment variable +ENV PUBLIC_URL /${APP_SUBFOLDER}/ + +# build the react app +# RUN npm run build +RUN if [ -z "$APP_SUBFOLDER" ]; then npm run build; else PUBLIC_URL=$PUBLIC_URL npm run build; fi + # production environment FROM node:14-slim RUN printf '\n\n- Copy application files\n' -ARG APP_SUBFOLDER=network-resurrector - COPY --from=builder /app/build ./application/${APP_SUBFOLDER} COPY --from=builder /app/build/index.html ./application/ +COPY --from=builder /app/setenv.js ./application/setenv.js #install static server RUN npm install -g serve @@ -35,4 +44,4 @@ WORKDIR / EXPOSE 80 -CMD ["sh", "-c", "serve -s application -p 80"] \ No newline at end of file +CMD ["sh", "-c", "node setenv.js && serve -s application -p 80"] \ No newline at end of file diff --git a/public/env.js b/public/env.js new file mode 100644 index 0000000..433c995 --- /dev/null +++ b/public/env.js @@ -0,0 +1,2 @@ +// In this file will be injected the environment variables that will overwrite the application configurations. +window.env = {}; diff --git a/public/index.html b/public/index.html index 2ebda86..3d2deb4 100644 --- a/public/index.html +++ b/public/index.html @@ -32,6 +32,7 @@ rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" /> +