From 10dd34ffd7a4743ddcb022d08bbfadbe9de25969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Charlier?= Date: Thu, 28 Nov 2024 12:55:32 +0100 Subject: [PATCH] Adjust container for prod - prod entrypoint makes sure the database schema is up-to-date but doesn't add data - dev entrypoint makes sure the database schema is up-to-date and creates admin user, etc. - allow override of LOG_LEVEL via environment variable Change-Id: Id56975f2f7abab324f6603930b71fcedb57dd3d1 --- Dockerfile | 12 ++++++------ dci/settings.py | 2 +- entrypoint-devenv.sh | 17 +++++++++++++++++ entrypoint.sh | 2 +- gunicorn.conf.py | 1 + 5 files changed, 26 insertions(+), 8 deletions(-) create mode 100755 entrypoint-devenv.sh diff --git a/Dockerfile b/Dockerfile index 5f27c45aa..2c4d300f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,14 +11,14 @@ WORKDIR /opt/dci-control-server COPY requirements.txt setup.py /opt/dci-control-server/ RUN microdnf update && \ - microdnf -y install python3-pip python3-wheel && \ - microdnf -y install python3-devel gcc postgresql-devel && \ - pip3 --no-cache-dir install -r requirements.txt && \ - microdnf -y remove python3-devel gcc postgresql-devel && \ - microdnf -y clean all + microdnf -y install python3-pip python3-wheel && \ + microdnf -y install python3-devel gcc postgresql-devel && \ + pip3 --no-cache-dir install -r requirements.txt && \ + microdnf -y remove python3-devel gcc postgresql-devel && \ + microdnf -y clean all # install source after -COPY entrypoint.sh /usr/local/sbin/ +COPY entrypoint-devenv.sh entrypoint.sh /usr/local/sbin/ COPY gunicorn.conf.py /etc/ COPY . /opt/dci-control-server/ diff --git a/dci/settings.py b/dci/settings.py index 4e17f6054..56aa7cbff 100644 --- a/dci/settings.py +++ b/dci/settings.py @@ -85,7 +85,7 @@ # Logging related parameters -LOG_LEVEL = "INFO" +LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") LOG_FORMAT = "[%(asctime)s] %(levelname)-8s %(name)-12s %(message)s" diff --git a/entrypoint-devenv.sh b/entrypoint-devenv.sh new file mode 100755 index 000000000..93cd6870f --- /dev/null +++ b/entrypoint-devenv.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if ! python3 bin/dci-wait-for-db; then + echo "Unable to wait for the DB. Exiting." 1>&2 + exit 0 +fi + +if ! python3 bin/dci-dbinit; then + echo "Unable to init the DB. Exiting." 1>&2 + exit 0 +fi + +pubkey=$(python3 bin/dci-get-pem-ks-key.py ${SSO_URL} ${SSO_REALM}) + +export SSO_PUBLIC_KEY="$pubkey" +echo $SSO_PUBLIC_KEY +exec "$@" diff --git a/entrypoint.sh b/entrypoint.sh index 93cd6870f..9ff3cf543 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,7 +5,7 @@ if ! python3 bin/dci-wait-for-db; then exit 0 fi -if ! python3 bin/dci-dbinit; then +if ! python3 bin/dci-dbsync then echo "Unable to init the DB. Exiting." 1>&2 exit 0 fi diff --git a/gunicorn.conf.py b/gunicorn.conf.py index bd6040f84..3b64169ca 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -3,3 +3,4 @@ default_nb_workers = multiprocessing.cpu_count() * 2 + 1 workers = int(os.getenv("DCI_NB_WORKERS", default_nb_workers)) +accesslog = "-"