From f05e358045e4fb82d710f86d2cdd8dafe09b3974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C5=BEe=20=C5=BDitnik?= <anze.zitnik@xlab.si> Date: Mon, 30 May 2022 15:08:01 +0000 Subject: [PATCH] Enable setting of API URL via environment variable. --- .env.production | 2 +- Dockerfile | 4 +++- README.md | 7 +++---- entrypoint.sh | 5 +++++ 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 entrypoint.sh diff --git a/.env.production b/.env.production index 06db81f7..58fe7e1d 100644 --- a/.env.production +++ b/.env.production @@ -1 +1 @@ -VUE_APP_API="https://cce-api-dev.k8s.medina.esilab.org" +VUE_APP_API="<<CCE_API_URL>>" diff --git a/Dockerfile b/Dockerfile index 18a2c573..0b6c311e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,8 @@ RUN rm -rf /usr/share/nginx/html/* # Copy from build stage COPY --from=build-stage /app/dist /usr/share/nginx/html +COPY --from=build-stage /app/entrypoint.sh /root +RUN chmod u+x /root/entrypoint.sh EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD /root/entrypoint.sh \ No newline at end of file diff --git a/README.md b/README.md index f4697bf1..f17d8a1a 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,7 @@ docker run -p 8081:80 registry-gitlab.xlab.si/medina/cce-frontend:latest Before pushing to master check if version needs to be updated in [package.json](package.json#L3). This version is also used for tagging docker image at CI. -## Setting API url +## Setting API URL -You can set the API URL in the environment file. -For local development (npm run serve) it is set in [.env.development](.env.development) and for production (docker run) in [.env.production](.env.production). -The environment must be set up before build. \ No newline at end of file +You can set the API URL using the `CCE_API_URL` environment variable. +By default (if unset) the URL used is MEDINA k8s dev deploy: https://cce-api-dev.k8s.medina.esilab.org diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..5278b11c --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +URL="${CCE_API_URL:-https://cce-api-dev.k8s.medina.esilab.org}" + +sed -i "s|<<CCE_API_URL>>|${CCE_API_URL}|" /usr/share/nginx/html/js/app.*.js + +nginx -g 'daemon off;' -- GitLab