Set default app env for local development to "local"

This commit is contained in:
Daniel Egger 2023-06-01 21:48:35 +02:00
parent 281b016df0
commit 800a07ba7e
19 changed files with 24 additions and 31 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:
```bash
export IT_APP_ENVIRONMENT=development
export IT_APP_ENVIRONMENT=local
```
See `.env_secrets/local_daniel.env` for more possible environment variables.

View File

@ -73,7 +73,8 @@ def main(app_name, image_name, environment_file):
container_http_port=7555,
environment_variables={
# 'DJANGO_SETTINGS_MODULE': 'config.settings.base',
"IT_APP_ENVIRONMENT": env.str("IT_APP_ENVIRONMENT", "caprover_feature"),
"IT_APP_ENVIRONMENT": env.str("IT_APP_ENVIRONMENT", "dev-feature"),
"IT_DEFAULT_ADMIN_PASSWORD": env.str("fWwoQzreIS5uztLOyF8jJpS9M"),
"POSTGRES_HOST": f"srv-captain--{app_name}-postgres",
"POSTGRES_PORT": 5432,
"POSTGRES_DB": db_name,
@ -88,6 +89,7 @@ def main(app_name, image_name, environment_file):
"IT_DJANGO_DEBUG": "false",
"IT_SERVE_VUE": "false",
"IT_ALLOW_LOCAL_LOGIN": "true",
"IT_DJANGO_LOGGING_CONF": "IT_DJANGO_LOGGING_CONF_JSON_FILE",
},
)

View File

@ -13,7 +13,7 @@ export PATH="$PWD/vbvvenv/bin:$PATH"
docker login --username=iterativ --password=$DOCKER_PASSWORD_TOKEN
# only used for `python manage.py collectstatic` so value doesn't matter
export IT_APP_ENVIRONMENT=development
export IT_APP_ENVIRONMENT=dev
pip install -r $BITBUCKET_CLONE_DIR/server/requirements/requirements-dev.txt

13
env/docker_local.env vendored
View File

@ -1,13 +0,0 @@
# PostgreSQL
# ------------------------------------------------------------------------------
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=vbv_lernwelt
POSTGRES_USER=postgres
POSTGRES_PASSWORD=hNqfCdG6bwCLcnfboDtNM1L2Hiwp8GuKp1DJ6t2rcKl15Vls2QbByoIZ6IQlciKM
# General
# ------------------------------------------------------------------------------
IT_DJANGO_LOCAL_DOCKER=True
IPYTHONDIR=/app/.ipython
IT_APP_ENVIRONMENT=local

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.

Binary file not shown.

View File

@ -1 +1 @@
export IT_APP_ENVIRONMENT='development'
export IT_APP_ENVIRONMENT=local

View File

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

View File

@ -7,7 +7,7 @@ import django
sys.path.append("../server")
os.environ.setdefault("IT_APP_ENVIRONMENT", "development")
os.environ.setdefault("IT_APP_ENVIRONMENT", "local")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.base")
django.setup()
@ -16,12 +16,16 @@ from wagtail.models import Page
def main():
from django.conf import settings
settings.DEBUG = True
from django.db import connection
from django.db import reset_queries
reset_queries()
page = Page.objects.get(slug='versicherungsvermittlerin', locale__language_code='de-CH')
page = Page.objects.get(
slug="versicherungsvermittlerin", locale__language_code="de-CH"
)
serializer = page.specific.get_serializer_class()(page.specific)
print(serializer.data)
@ -29,5 +33,5 @@ def main():
print(len(connection.queries))
if __name__ == '__main__':
if __name__ == "__main__":
main()

View File

@ -14,13 +14,18 @@ APPS_DIR = SERVER_ROOT_DIR / "vbv_lernwelt"
env = Env()
env.read_env()
# set to "development" for local development
# set to "local" for local development
APP_ENVIRONMENT = env("IT_APP_ENVIRONMENT")
# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool("IT_DJANGO_DEBUG", True if APP_ENVIRONMENT == "development" else False)
DEBUG = env.bool("IT_DJANGO_DEBUG", True if APP_ENVIRONMENT == "local" else False)
# check that IT_DEFAULT_ADMIN_PASSWORD is set
if not DEBUG:
# fails if not set
env.str("IT_DEFAULT_ADMIN_PASSWORD")
# Local time zone. Choices are
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
@ -614,7 +619,7 @@ if FILE_UPLOAD_STORAGE == "s3":
AWS_PRESIGNED_EXPIRY = env.int("AWS_PRESIGNED_EXPIRY", default=300) # seconds
if APP_ENVIRONMENT == "development":
if APP_ENVIRONMENT.startswith("dev"):
# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development
INSTALLED_APPS = ["whitenoise.runserver_nostatic"] + INSTALLED_APPS # noqa F405
@ -697,11 +702,6 @@ if APP_ENVIRONMENT in ["production", "caprover"] or APP_ENVIRONMENT.startswith(
default="[VBV Lernwelt]",
)
# ADMIN
# ------------------------------------------------------------------------------
# Django Admin URL regex.
ADMIN_URL = env("IT_DJANGO_ADMIN_URL", "admin/")
# Anymail
# ------------------------------------------------------------------------------
# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail

View File

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

View File

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