Rework VITE_* variables...

This commit is contained in:
Daniel Egger 2023-06-02 00:10:34 +02:00
parent f02e37afb7
commit 3158033d57
18 changed files with 24 additions and 11 deletions

View File

@ -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: You have to set up at least the following environment variables:
```bash ```bash
export VITE_APP_ENVIRONMENT=local export IT_APP_ENVIRONMENT=local
``` ```
See `.env_secrets/local_daniel.env` for more possible environment variables. See `.env_secrets/local_daniel.env` for more possible environment variables.

View File

@ -72,7 +72,7 @@ def main(app_name, image_name, environment_file):
image_name=image_name, image_name=image_name,
container_http_port=7555, container_http_port=7555,
environment_variables={ 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": env.str(
"IT_DEFAULT_ADMIN_PASSWORD", "ACEEs0DCmNaPxdoNV8vhccuCTRl9b" "IT_DEFAULT_ADMIN_PASSWORD", "ACEEs0DCmNaPxdoNV8vhccuCTRl9b"
), ),

View File

@ -25,11 +25,22 @@ function generate_default_app_name() {
# take app name as first argument or use the default generated app name # take app name as first argument or use the default generated app name
APP_NAME=${1:-$(generate_default_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" echo "Deploy to $APP_NAME"
# create client for django # create client for django
npm run build 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 if [[ "$APP_NAME" == "prod-azure" ]]; then
# build and push azure docker container # build and push azure docker container

View File

@ -8,7 +8,9 @@ import * as log from "loglevel";
log.debug("AppFooter created"); log.debug("AppFooter created");
const userStore = useUserStore(); 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) { async function changeLocale(language: AvailableLanguages) {
userStore.setUserLanguages(language); userStore.setUserLanguages(language);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
export VITE_APP_ENVIRONMENT=local export IT_APP_ENVIRONMENT=local

View File

@ -3,7 +3,7 @@
# set location to script directory # set location to script directory
cd "${0%/*}" cd "${0%/*}"
export VITE_APP_ENVIRONMENT=local export IT_APP_ENVIRONMENT=local
export DJANGO_SETTINGS_MODULE=config.settings.test_cypress export DJANGO_SETTINGS_MODULE=config.settings.test_cypress
export DJANGO_PORT=8001 export DJANGO_PORT=8001
export PGDATABASE=vbv_lernwelt_cypress export PGDATABASE=vbv_lernwelt_cypress

View File

@ -7,7 +7,7 @@ import django
sys.path.append("../server") 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") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.base")
django.setup() django.setup()

View File

@ -15,7 +15,7 @@ env = Env()
env.read_env() env.read_env()
# set to "local" for local development # set to "local" for local development
APP_ENVIRONMENT = env("VITE_APP_ENVIRONMENT") APP_ENVIRONMENT = env("IT_APP_ENVIRONMENT")
# GENERAL # GENERAL
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -555,7 +555,7 @@ OAUTH = {
"authorize_params": IT_OAUTH_AUTHORIZE_PARAMS, "authorize_params": IT_OAUTH_AUTHORIZE_PARAMS,
"access_token_params": IT_OAUTH_AUTHORIZE_PARAMS, "access_token_params": IT_OAUTH_AUTHORIZE_PARAMS,
"api_base_url": env( "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/", default="https://sso.test.b.lernetz.host/auth/realms/vbv/protocol/openid-connect/",
), ),
"local_redirect_uri": env( "local_redirect_uri": env(

View File

@ -1,7 +1,7 @@
# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position
import os import os
os.environ["VITE_APP_ENVIRONMENT"] = "local" os.environ["IT_APP_ENVIRONMENT"] = "local"
from .base import * # noqa from .base import * # noqa

View File

@ -1,7 +1,7 @@
# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position
import os import os
os.environ["VITE_APP_ENVIRONMENT"] = "local" os.environ["IT_APP_ENVIRONMENT"] = "local"
from .base import * # noqa from .base import * # noqa