diff --git a/Dockerfile b/Dockerfile index 92b8d6a..5a0fa3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,5 @@ RUN npm run build # Stage 2: Package up with the webserver FROM nginx:alpine AS final -COPY --from=build /build/dist/frontend /usr/share/nginx/html \ No newline at end of file +COPY --from=build /build/dist/frontend /usr/share/nginx/html +CMD ["/bin/sh", "-c", "envsubst < /usr/share/nginx/html/assets/env.template.js > /usr/share/nginx/html/assets/env.js && exec nginx -g 'daemon off;'"] \ No newline at end of file diff --git a/src/assets/env.js b/src/assets/env.js new file mode 100644 index 0000000..5b334ef --- /dev/null +++ b/src/assets/env.js @@ -0,0 +1,7 @@ +(function(window) { + window["env"] = window["env"] || {}; + + // Environment variables + window["env"]["apiUrl"] = "http://localhost:5001"; + window["env"]["debug"] = false; + })(this); \ No newline at end of file diff --git a/src/assets/env.template.js b/src/assets/env.template.js new file mode 100644 index 0000000..ccceb37 --- /dev/null +++ b/src/assets/env.template.js @@ -0,0 +1,7 @@ +(function(window) { + window.env = window.env || {}; + + // Environment variables + window["env"]["apiUrl"] = "${API_URL}"; + window["env"]["debug"] = "${DEBUG}"; + })(this); \ No newline at end of file diff --git a/src/environments/environment.ts b/src/environments/environment.ts index a670c0c..b802079 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,7 +4,8 @@ export const environment = { production: false, - apiUrl: 'https://localhost:5001' + apiUrl: window["env"]["apiUrl"] || "default", + debug: window["env"]["debug"] || false }; /* diff --git a/src/index.html b/src/index.html index 3af61ec..506492d 100644 --- a/src/index.html +++ b/src/index.html @@ -6,6 +6,7 @@ +