diff --git a/Dockerfile b/Dockerfile index f4570ba..60a7de2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # ---------------------------------------------------- # Base-image # ---------------------------------------------------- -FROM python:3.9-slim-buster as common-base +FROM python:3.9-slim-bookworm as common-base # Django directions: https://blog.ploetzli.ch/2020/efficient-multi-stage-build-django-docker/ # Pip on docker : https://pythonspeed.com/articles/multi-stage-docker-python/ # https://blog.mikesir87.io/2018/07/leveraging-multi-stage-builds-single-dockerfile-dev-prod/ diff --git a/ark/models.py b/ark/models.py index 317f032..fbf6384 100644 --- a/ark/models.py +++ b/ark/models.py @@ -135,7 +135,7 @@ def clean(self): @classmethod def create(cls, naan: Naan, shoulder: Shoulder): - noid = generate_noid(os.environ.get("ARKLET_NOID_LENGTH", 8)) + noid = generate_noid(int(os.environ.get("ARKLET_NOID_LENGTH", 8))) ark_prefix = f"{naan.naan}{shoulder.shoulder}" base_ark_string = f"{ark_prefix}{noid}" check_digit = noid_check_digit(base_ark_string) diff --git a/arklet/settings.py b/arklet/settings.py index 5d229ac..e8f4312 100644 --- a/arklet/settings.py +++ b/arklet/settings.py @@ -19,7 +19,7 @@ env = environ.Env( # set default values - ARKLET_HOST=(str, "127.0.0.1"), + ARKLET_HOST=(list, ["127.0.0.1"]), ARKLET_DEBUG=(bool, False), ARKLET_POSTGRES_NAME=(str, "arklet"), ARKLET_POSTGRES_HOST=(str, "127.0.0.1"), @@ -48,19 +48,20 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env("ARKLET_DEBUG") -ALLOWED_HOSTS = [ - env("ARKLET_HOST"), -] +ALLOWED_HOSTS = env.list("ARKLET_HOST") CSRF_TRUSTED_ORIGINS = [ f"http://*.127.0.0.1", - f"http://*.127.0.0.1:{env('ARKLET_PORT')}", - f"http://*.{env('ARKLET_HOST')}", - f"https://*.{env('ARKLET_HOST')}", - f"http://*.{env('ARKLET_HOST')}:{env('ARKLET_PORT')}", - f"https://*.{env('ARKLET_HOST')}:{env('ARKLET_PORT')}", + f"http://*.127.0.0.1:{env('ARKLET_PORT')}" ] +for allowed_host in ALLOWED_HOSTS: + CSRF_TRUSTED_ORIGINS = CSRF_TRUSTED_ORIGINS + [ + f"http://*.{allowed_host}", + f"https://*.{allowed_host}", + f"http://*.{allowed_host}:{env('ARKLET_PORT')}", + f"https://*.{allowed_host}:{env('ARKLET_PORT')}", + ] # Application definition diff --git a/docker/Dockerfile b/docker/Dockerfile index 177d748..820b2dd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ # ---------------------------------------------------- # Base-image # ---------------------------------------------------- -FROM python:3.9-slim-buster as common-base +FROM python:3.9-slim-bookworm as common-base # Django directions: https://blog.ploetzli.ch/2020/efficient-multi-stage-build-django-docker/ # Pip on docker : https://pythonspeed.com/articles/multi-stage-docker-python/ # https://blog.mikesir87.io/2018/07/leveraging-multi-stage-builds-single-dockerfile-dev-prod/ diff --git a/requirements.txt b/requirements.txt index 774007b..129a10c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,9 +11,9 @@ MarkupSafe==2.0.1 mypy-extensions==0.4.3 pathspec==0.9.0 platformdirs==2.4.0 -psycopg2-binary==2.9.1 +psycopg2-binary==2.9.10 pytz==2021.3 -PyYAML==6.0 +PyYAML==6.0.2 regex==2021.10.23 sentry-sdk==1.4.3 sqlparse==0.4.2