From 39bc758e39a66a6d73286c0938dbcca6c846eb4a Mon Sep 17 00:00:00 2001 From: "joel.clement" Date: Tue, 12 Sep 2023 16:13:57 +0200 Subject: [PATCH] dockerisation up Dockerfile & startup --- backend/Dockerfile | 13 +++++++------ install/assets/docker_startup.sh | 16 +++++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index aa45799087..19ee3e90a0 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,12 +1,11 @@ # syntax=docker/dockerfile:1.2 -FROM python:3.9-bullseye AS build +FROM python:3.11-bookworm AS build ENV PIP_ROOT_USER_ACTION=ignore RUN --mount=type=cache,target=/root/.cache \ pip install --upgrade pip setuptools wheel - FROM build AS build-habref WORKDIR /build/ COPY /backend/dependencies/Habref-api-module . @@ -107,19 +106,21 @@ RUN --mount=type=cache,target=/root/.npm \ npm ci --omit=dev -FROM python:3.9-bullseye AS wheels-light +FROM python:3.11-bookworm AS wheels-light ENV PIP_ROOT_USER_ACTION=ignore RUN --mount=type=cache,target=/root/.cache \ pip install --upgrade pip setuptools wheel WORKDIR /dist -ENV GEONATURE_STATIC_PATH=/dist/static/ +ENV GEONATURE_STATIC_FOLDER=/dist/static/ COPY /backend/static/ ./static/ COPY --from=node /dist/node_modules/ ./static/node_modules/ -ENV GEONATURE_CUSTOM_STATIC_PATH=/dist/custom/ +ENV GEONATURE_CUSTOM_STATIC_FOLDER=/dist/custom/ RUN mkdir custom -ENV GEONATURE_MEDIA_PATH=/dist/media/ +ENV DATA_DIRECTORY=/dist/data +RUN mkdir data +ENV GEONATURE_MEDIA_FOLDER=/dist/media/ RUN mkdir -p media/attachments WORKDIR /dist/geonature diff --git a/install/assets/docker_startup.sh b/install/assets/docker_startup.sh index fce7099001..f47f0343f6 100755 --- a/install/assets/docker_startup.sh +++ b/install/assets/docker_startup.sh @@ -1,10 +1,10 @@ #!/bin/bash # script /install/assert/docker_startup.sh -# fait appel à /install/03b_populate_db.sh (renommé /populate_db.sh dans le docker) +# ce script fait appel à /install/03b_populate_db.sh (renommé /populate_db.sh dans le docker) # pour lancer les migrations alembic et les commandes d'ajouts de donneés (taxref, sensibilité) -# si la variable d'environnement GEONATURE_POPULATE_DB est définie à True -# sinon il lance gunicorn directement +# sauf si la variable d'environnement GEONATURE_SKIP_POPULATE_DB est définie à True, +# dans ce cas il lance gunicorn directement set -o errexit set -o pipefail @@ -12,7 +12,10 @@ set -o nounset # creer les tables et peupler la base -if [ "${GEONATURE_POPULATE_DB}" = true ]; then +if [ "${GEONATURE_SKIP_POPULATE_DB}" = true ]; then + # pass + : +else . /populate_db.sh if [ "$usershub" = true ]; then @@ -31,6 +34,8 @@ if [ "${GEONATURE_POPULATE_DB}" = true ]; then geonature db upgrade taxhub-admin@head fi fi + + geonature upgrade-modules-db fi # lancement de l'application @@ -38,4 +43,5 @@ gunicorn "geonature:create_app()" \ --name=geonature \ --workers=2 \ --threads=2 \ - --bind=0.0.0.0:8000 \ No newline at end of file + --bind=0.0.0.0:8000 \ + --reload --reload-extra-file="${GEONATURE_CONFIG_FILE}" \ No newline at end of file