diff --git a/README.md b/README.md index aec9a737..e13abd6e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ See `.tool-versions` file for used django and node version You have to set up at least the following environment variables: ```bash -export VITE_APP_ENVIRONMENT=local +export IT_APP_ENVIRONMENT=local ``` See `.env_secrets/local_daniel.env` for more possible environment variables. diff --git a/caprover_create_app.py b/caprover_create_app.py index ff90aab1..00688bf5 100644 --- a/caprover_create_app.py +++ b/caprover_create_app.py @@ -72,7 +72,7 @@ def main(app_name, image_name, environment_file): image_name=image_name, container_http_port=7555, environment_variables={ - "VITE_APP_ENVIRONMENT": env.str("VITE_APP_ENVIRONMENT", "dev-feature"), + "IT_APP_ENVIRONMENT": env.str("IT_APP_ENVIRONMENT", "dev-feature"), "IT_DEFAULT_ADMIN_PASSWORD": env.str( "IT_DEFAULT_ADMIN_PASSWORD", "ACEEs0DCmNaPxdoNV8vhccuCTRl9b" ), diff --git a/caprover_deploy.sh b/caprover_deploy.sh index b965b1e1..2cb0c455 100755 --- a/caprover_deploy.sh +++ b/caprover_deploy.sh @@ -25,11 +25,22 @@ function generate_default_app_name() { # take app name as first argument or use the default generated app name APP_NAME=${1:-$(generate_default_app_name)} +# VITE_* variables need to be present at build time +VITE_APP_ENVIRONMENT="dev-$APP_NAME" + +if [[ "$APP_NAME" == "myvbv-stage" ]]; then + VITE_OAUTH_API_BASE_URL="https://vbvtst.b2clogin.com/vbvtst.onmicrosoft.com/b2c_1_signupandsignin/oauth2/v2.0/" + VITE_APP_ENVIRONMENT="stage-caprover" +elif [[ "$APP_NAME" == prod* ]]; then + VITE_OAUTH_API_BASE_URL="https://edumgr.b2clogin.com/edumgr.onmicrosoft.com/b2c_1_signupandsignin/oauth2/v2.0/" + VITE_APP_ENVIRONMENT=$APP_NAME +fi + echo "Deploy to $APP_NAME" # create client for django npm run build -VITE_APP_ENVIRONMENT=local python server/manage.py collectstatic --no-input +IT_APP_ENVIRONMENT=local python server/manage.py collectstatic --no-input if [[ "$APP_NAME" == "prod-azure" ]]; then # build and push azure docker container diff --git a/client/src/components/AppFooter.vue b/client/src/components/AppFooter.vue index 1223302a..dc50187c 100644 --- a/client/src/components/AppFooter.vue +++ b/client/src/components/AppFooter.vue @@ -8,7 +8,9 @@ import * as log from "loglevel"; log.debug("AppFooter created"); const userStore = useUserStore(); -const hideVersion = import.meta.env.VITE_APP_ENVIRONMENT.startsWith("prod"); +const hideVersion = (import.meta.env.VITE_APP_ENVIRONMENT || "local").startsWith( + "prod" +); async function changeLocale(language: AvailableLanguages) { userStore.setUserLanguages(language); diff --git a/env_secrets/caprover_dev.env b/env_secrets/caprover_dev.env index 41b28b09..26b83797 100644 Binary files a/env_secrets/caprover_dev.env and b/env_secrets/caprover_dev.env differ diff --git a/env_secrets/caprover_prod.env b/env_secrets/caprover_prod.env index 114f258d..286463c3 100644 Binary files a/env_secrets/caprover_prod.env and b/env_secrets/caprover_prod.env differ diff --git a/env_secrets/caprover_stage.env b/env_secrets/caprover_stage.env index 4866da45..10504c3e 100644 Binary files a/env_secrets/caprover_stage.env and b/env_secrets/caprover_stage.env differ diff --git a/env_secrets/local_chrigu.env b/env_secrets/local_chrigu.env index 0810257d..b012626b 100644 Binary files a/env_secrets/local_chrigu.env and b/env_secrets/local_chrigu.env differ diff --git a/env_secrets/local_daniel.env b/env_secrets/local_daniel.env index 9bf0493d..9b641f2e 100644 Binary files a/env_secrets/local_daniel.env and b/env_secrets/local_daniel.env differ diff --git a/env_secrets/local_elia.env b/env_secrets/local_elia.env index 3fa0d8a9..920f089e 100644 Binary files a/env_secrets/local_elia.env and b/env_secrets/local_elia.env differ diff --git a/env_secrets/local_lorenz.env b/env_secrets/local_lorenz.env index 2dec8268..22665c98 100644 Binary files a/env_secrets/local_lorenz.env and b/env_secrets/local_lorenz.env differ diff --git a/env_secrets/prod-azure.json b/env_secrets/prod-azure.json index 89afb54d..104f4295 100644 Binary files a/env_secrets/prod-azure.json and b/env_secrets/prod-azure.json differ diff --git a/example.env b/example.env index ccda9030..cebd3ce6 100644 --- a/example.env +++ b/example.env @@ -1 +1 @@ -export VITE_APP_ENVIRONMENT=local +export IT_APP_ENVIRONMENT=local diff --git a/prepare_server_cypress.sh b/prepare_server_cypress.sh index 68bee3e9..0bc71716 100755 --- a/prepare_server_cypress.sh +++ b/prepare_server_cypress.sh @@ -3,7 +3,7 @@ # set location to script directory cd "${0%/*}" -export VITE_APP_ENVIRONMENT=local +export IT_APP_ENVIRONMENT=local export DJANGO_SETTINGS_MODULE=config.settings.test_cypress export DJANGO_PORT=8001 export PGDATABASE=vbv_lernwelt_cypress diff --git a/scripts/count_queries.py b/scripts/count_queries.py index 46318b64..905f001e 100644 --- a/scripts/count_queries.py +++ b/scripts/count_queries.py @@ -7,7 +7,7 @@ import django sys.path.append("../server") -os.environ.setdefault("VITE_APP_ENVIRONMENT", "local") +os.environ.setdefault("IT_APP_ENVIRONMENT", "local") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.base") django.setup() diff --git a/server/config/settings/base.py b/server/config/settings/base.py index 37ee082d..2632175c 100644 --- a/server/config/settings/base.py +++ b/server/config/settings/base.py @@ -15,7 +15,7 @@ env = Env() env.read_env() # set to "local" for local development -APP_ENVIRONMENT = env("VITE_APP_ENVIRONMENT") +APP_ENVIRONMENT = env("IT_APP_ENVIRONMENT") # GENERAL # ------------------------------------------------------------------------------ @@ -555,7 +555,7 @@ OAUTH = { "authorize_params": IT_OAUTH_AUTHORIZE_PARAMS, "access_token_params": IT_OAUTH_AUTHORIZE_PARAMS, "api_base_url": env( - "VITE_OAUTH_API_BASE_URL", + "IT_OAUTH_API_BASE_URL", default="https://sso.test.b.lernetz.host/auth/realms/vbv/protocol/openid-connect/", ), "local_redirect_uri": env( diff --git a/server/config/settings/test.py b/server/config/settings/test.py index f78911c5..5878c8c8 100644 --- a/server/config/settings/test.py +++ b/server/config/settings/test.py @@ -1,7 +1,7 @@ # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position import os -os.environ["VITE_APP_ENVIRONMENT"] = "local" +os.environ["IT_APP_ENVIRONMENT"] = "local" from .base import * # noqa diff --git a/server/config/settings/test_cypress.py b/server/config/settings/test_cypress.py index bba19d71..a82cbe93 100644 --- a/server/config/settings/test_cypress.py +++ b/server/config/settings/test_cypress.py @@ -1,7 +1,7 @@ # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position import os -os.environ["VITE_APP_ENVIRONMENT"] = "local" +os.environ["IT_APP_ENVIRONMENT"] = "local" from .base import * # noqa