diff --git a/GUI/.dockerignore b/GUI/.dockerignore new file mode 100644 index 00000000..ab4f96a1 --- /dev/null +++ b/GUI/.dockerignore @@ -0,0 +1,7 @@ +node_modules +npm-debug.log +build +.git +*.md +.gitignore +.env.development diff --git a/GUI/Dockerfile b/GUI/Dockerfile index ffe83397..1fe950be 100644 --- a/GUI/Dockerfile +++ b/GUI/Dockerfile @@ -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" ] diff --git a/GUI/nginx/scripts/env.sh b/GUI/nginx/scripts/env.sh new file mode 100644 index 00000000..de80ffdc --- /dev/null +++ b/GUI/nginx/scripts/env.sh @@ -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;' || $@ diff --git a/docker-compose.yml b/docker-compose.yml index b7ce6475..75308e49 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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