Skip to content

Commit

Permalink
dockerisation up Dockerfile & startup
Browse files Browse the repository at this point in the history
  • Loading branch information
joelclems committed Sep 12, 2023
1 parent 06923fa commit 39bc758
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
13 changes: 7 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 .
Expand Down Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions install/assets/docker_startup.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#!/bin/bash

# script <geonature>/install/assert/docker_startup.sh
# fait appel à <geonature>/install/03b_populate_db.sh (renommé /populate_db.sh dans le docker)
# ce script fait appel à <geonature>/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
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
Expand All @@ -31,11 +34,14 @@ if [ "${GEONATURE_POPULATE_DB}" = true ]; then
geonature db upgrade taxhub-admin@head
fi
fi

geonature upgrade-modules-db
fi

# lancement de l'application
gunicorn "geonature:create_app()" \
--name=geonature \
--workers=2 \
--threads=2 \
--bind=0.0.0.0:8000
--bind=0.0.0.0:8000 \
--reload --reload-extra-file="${GEONATURE_CONFIG_FILE}"

0 comments on commit 39bc758

Please sign in to comment.