Skip to content

Commit

Permalink
added envs
Browse files Browse the repository at this point in the history
  • Loading branch information
bomzheg committed Jun 12, 2024
1 parent 9e3cca7 commit 4da54cf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ FROM nginx:latest
COPY --from=build /usr/local/app/dist/shvatka/browser /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
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;'"]

9 changes: 9 additions & 0 deletions src/assets/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(function(window) {
window["env"] = window["env"] || {};

// Environment variables
window["env"]["apiUrl"] = "https://shvatka-test.bomzheg.dev/api";
window["env"]["mainUrl"] = "https://shvatka-test.bomzheg.dev";
window["env"]["botUsername"] = 'shvatkatestbot';
window["env"]["baseHref"] = "/"
})(this);
9 changes: 9 additions & 0 deletions src/assets/env.template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(function(window) {
window["env"] = window["env"] || {};

// Environment variables
window["env"]["apiUrl"] = "${SHVATKA_UI_API_URL}";
window["env"]["mainUrl"] = "${SHVATKA_UI_MAIN_URL}";
window["env"]["botUsername"] = "${SHVATKA_UI_BOT_USERNAME}";
window["env"]["baseHref"] = "${SHVATKA_UI_BASE_HREF}"
})(this);
10 changes: 5 additions & 5 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

const env = (window as { [key: string]: any })["env"] as { [key: string]: string };
export const environment = {
mainUrl: "https://shvatka-test.bomzheg.dev",
apiUrl: "https://shvatka-test.bomzheg.dev/api",
botUsername: "shvatkatestbot",
baseHref: "/",
mainUrl: env["mainUrl"],
apiUrl: env["apiUrl"],
botUsername: env["botUsername"],
baseHref: env["baseHref"] || "/",
};
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<!-- Load environment variables -->
<script src="assets/env.js"></script>
</head>
<body class="mat-typography">
<app-root></app-root>
Expand Down

0 comments on commit 4da54cf

Please sign in to comment.