File tree Expand file tree Collapse file tree 5 files changed +28
-52
lines changed Expand file tree Collapse file tree 5 files changed +28
-52
lines changed Original file line number Diff line number Diff line change 11REACT_APP_API_URL = http://localhost:4200
22PORT = 8080
3- VRT_VERSION = 4.20 .0
3+ VRT_VERSION = 5.0 .0
Original file line number Diff line number Diff line change @@ -6,17 +6,19 @@ FROM node:18-alpine3.18 AS builder
66WORKDIR /app
77
88# Copy all files from the repo to /app
9- COPY . .
9+ COPY /public ./public
10+ COPY /src ./src
11+ COPY index.html .
12+ COPY package*.json .
13+ COPY tsconfig.json .
14+ COPY vite.config.ts .
1015
1116# Install app dependencies
1217RUN npm ci --verbose
1318
1419# Build the ui
1520RUN npm run build
1621
17- # Create environment variable js file
18- RUN node generate-env-browser.js
19-
2022# ## STAGE 2: Run ###
2123# This image is around 5 megabytes
2224FROM nginx:1.25-alpine3.17-slim
@@ -26,7 +28,17 @@ COPY /nginx /etc/nginx/conf.d
2628EXPOSE 8080
2729EXPOSE 443
2830
29- COPY --from=builder /app/build /usr/share/nginx/html
30- COPY --from=builder /app/env-config.js /usr/share/nginx/html/
31+ WORKDIR /usr/share/nginx/html
32+
33+ # Copy built source
34+ COPY --from=builder /app/build .
35+
36+ # Copy override ENV script with default values
37+ COPY ./env.sh .
38+ COPY .env .
39+
40+ # Make our shell script executable
41+ RUN chmod +x env.sh
3142
32- # Nginx server will now start automatically.
43+ # Start Nginx server with override ENV variables script
44+ CMD ["/bin/sh" , "-c" , "/usr/share/nginx/html/env.sh && nginx -g \" daemon off;\" " ]
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ # (c) https://github.com/kunokdev/cra-runtime-environment-variables/blob/master/env.sh
3+ # line endings must be \n, not \r\n !
4+
5+ echo " window._env_ = {" > ./env-config.js
6+ awk -F ' =' ' { print $1 ": \"" (ENVIRON[$1] ? ENVIRON[$1] : $2) "\"," }' ./.env >> ./env-config.js
7+ echo " }" >> ./env-config.js
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3838 "uuid" : " ^9.0.0"
3939 },
4040 "scripts" : {
41- "start" : " node generate- env-browser.js && cp env-config.js ./public/ && vite" ,
41+ "start" : " chmod +x ./ env.sh && sh ./env.sh && cp env-config.js ./public/ && vite" ,
4242 "test" : " jest" ,
4343 "format" : " prettier --write integration_tests src *.js *.ts *.md" ,
4444 "build" : " vite build" ,
You can’t perform that action at this time.
0 commit comments