Skip to content

Commit

Permalink
Merge pull request #644 from 1AhmedYasser/fixed-ngnix
Browse files Browse the repository at this point in the history
Added Nginx Env Support
  • Loading branch information
varmoh authored May 24, 2024
2 parents 64e7273 + 6a15955 commit fc3f764
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
7 changes: 7 additions & 0 deletions GUI/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
npm-debug.log
build
.git
*.md
.gitignore
.env.development
5 changes: 4 additions & 1 deletion GUI/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ COPY ./nginx/http-nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build ./usr/buerokratt-chatbot/build/assets /usr/share/nginx/html/buerokratt-chatbot/chat/assets
COPY --from=build ./usr/buerokratt-chatbot/build/index.html /usr/share/nginx/html/buerokratt-chatbot
COPY --from=build ./usr/buerokratt-chatbot/build/favicon.ico /usr/share/nginx/html/buerokratt-chatbot
RUN apk add --no-cache bash
COPY ./nginx/scripts/env.sh /docker-entrypoint.d/env.sh
RUN chmod +x /docker-entrypoint.d/env.sh
EXPOSE 3001

CMD ["nginx", "-g", "daemon off;"]
ENTRYPOINT [ "bash", "/docker-entrypoint.d/env.sh" ]
12 changes: 12 additions & 0 deletions GUI/nginx/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
for envrow in $(printenv);
do
IFS='=' read -r key value <<< "${envrow}"
if [[ $key == "REACT_APP_"* ]]; then
for file in $(find /usr/share/nginx/html -type f \( -name '*.js' -o -name '*.css' \))
do
sed -i "s|{}.${key}|\"${value}\"|g" $file;
done
fi
done
[ -z "$@" ] && nginx -g 'daemon off;' || $@
11 changes: 10 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,18 @@ services:
- DEBUG_ENABLED=true
- CHOKIDAR_USEPOLLING=true
- PORT=3001
- REACT_APP_BUEROKRATT_CHATBOT_URL=http://buerokratt-chat:8086
- REACT_APP_MENU_URL=https://admin.dev.buerokratt.ee
- REACT_APP_MENU_PATH=/chat/menu.json
- REACT_APP_CONVERSATIONS_BASE_URL=http://localhost:8080/chat
- REACT_APP_TRAINING_BASE_URL=http://localhost:8080/training
- REACT_APP_ANALYTICS_BASE_URL=http://localhost:8080/analytics
- REACT_APP_SERVICES_BASE_URL=http://localhost:8080/services
- REACT_APP_SETTINGS_BASE_URL=http://localhost:8080/settings
- REACT_APP_MONITORING_BASE_URL=http://localhost:8080/monitoring
- REACT_APP_SERVICE_ID=conversations,settings,monitoring
build:
context: ./GUI
# target: web // To be used in production (Dockerfile)
dockerfile: Dockerfile.dev
ports:
- 3001:3001
Expand Down

0 comments on commit fc3f764

Please sign in to comment.