From 7a5f2a4e7059784eea164c82b4f9773e3e82f929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Mon, 11 Sep 2023 15:20:04 +0200 Subject: [PATCH] attempt to provide minimalist compose and images --- .env.dev | 51 ++--- .env.prod | 52 ++--- .env.prod.swp | Bin 0 -> 12288 bytes .github/workflows/docker.yml | 188 +++--------------- .gitignore | 9 +- .../postgres/initdb}/add-extensions.sql | 4 +- build/Dockerfile-geonature-backend | 6 +- build/Dockerfile-geonature-frontend | 6 +- .../config => config/geonature}/.gitkeep | 0 .../atlas/custom => config/taxhub}/.gitkeep | 0 .../config => config/usershub}/.gitkeep | 0 data/apps/atlas/config/config.py.sample | 105 ---------- data/apps/usershub/config/.gitkeep | 0 data/db/.gitkeep | 0 data/{apps => }/geonature/media/.gitkeep | 0 .../taxhub/config => taxhub/static}/.gitkeep | 0 .../taxhub/static => traefik/certs}/.gitkeep | 0 docker-compose.atlas.yml | 30 --- docker-compose.override.yml | 16 -- docker-compose.traefik.yml | 13 -- docker-compose.yml | 117 ++++++----- 21 files changed, 160 insertions(+), 437 deletions(-) create mode 100644 .env.prod.swp rename {db => assets/postgres/initdb}/add-extensions.sql (65%) rename {data/apps/atlas/config => config/geonature}/.gitkeep (100%) rename {data/apps/atlas/custom => config/taxhub}/.gitkeep (100%) rename {data/apps/geonature/config => config/usershub}/.gitkeep (100%) delete mode 100644 data/apps/atlas/config/config.py.sample delete mode 100644 data/apps/usershub/config/.gitkeep delete mode 100644 data/db/.gitkeep rename data/{apps => }/geonature/media/.gitkeep (100%) rename data/{apps/taxhub/config => taxhub/static}/.gitkeep (100%) rename data/{apps/taxhub/static => traefik/certs}/.gitkeep (100%) delete mode 100644 docker-compose.atlas.yml delete mode 100644 docker-compose.override.yml delete mode 100644 docker-compose.traefik.yml diff --git a/.env.dev b/.env.dev index 0106c48..5a288b7 100644 --- a/.env.dev +++ b/.env.dev @@ -1,33 +1,36 @@ +BASE_PROTOCOL="http" +HOST="localhost" + +HTTP_PORT=8081 +HTTPS_PORT=8083 + POSTGRES_USER="geonatadmin" POSTGRES_PASSWORD="geonatpasswd" POSTGRES_HOST="postgres" POSTGRES_DB="geonature2db" -POSTGRES_EXPOSED_PORT=5435 -GDS_HTTP_PORT=8081 -GDS_HTTPS_PORT=8083 - -HOST="localhost" +USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:latest" +USERSHUB_HOST="${HOST}:${HTTP_PORT}" +USERSHUB_PROTOCOL="${BASE_PROTOCOL}" +USERSHUB_DOMAIN="${HOST}" +USERSHUB_PREFIX="/usershub" +USERSHUB_SECRET_KEY="change me" -GDS_USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:develop" -GDS_USERSHUB_HOST="${HOST}:${GDS_HTTP_PORT}" -GDS_USERSHUB_DOMAIN="${HOST}" -GDS_USERSHUB_PREFIX="/usershub" +TAXHUB_IMAGE="ghcr.io/pnx-si/taxhub:latest" +TAXHUB_DOMAIN="${HOST}" +TAXHUB_PROTOCOL="${BASE_PROTOCOL}" +TAXHUB_HOST="${HOST}:${HTTP_PORT}" +TAXHUB_PREFIX="/taxhub" +TAXHUB_API_PREFIX="${TAXHUB_PREFIX}/api" -GDS_TAXHUB_IMAGE="ghcr.io/pnx-si/taxhub:develop" -GDS_TAXHUB_DOMAIN="${HOST}" -GDS_TAXHUB_HOST="${HOST}:${GDS_HTTP_PORT}" -GDS_TAXHUB_PREFIX="/taxhub" -GDS_TAXHUB_API_PREFIX="${GDS_TAXHUB_PREFIX}/api" -GDS_TAXHUB_PROTOCOL="http" +GEONATURE_DOMAIN="${HOST}" -GDS_GEONATURE_BACKEND_IMAGE="ghcr.io/pnx-si/geonature-backend:develop" -GDS_GEONATURE_DOMAIN="${HOST}" -GDS_GEONATURE_BACKEND_HOST="${HOST}:${GDS_HTTP_PORT}" -GDS_GEONATURE_BACKEND_PREFIX="/geonature/api" -GDS_GEONATURE_BACKEND_PROTOCOL="http" +GEONATURE_BACKEND_IMAGE="ghcr.io/pnx-si/geonature-backend-extended:latest" +GEONATURE_BACKEND_HOST="${HOST}:${HTTP_PORT}" +GEONATURE_BACKEND_PREFIX="/geonature/api" +GEONATURE_BACKEND_PROTOCOL="http" -GDS_GEONATURE_FRONTEND_IMAGE="ghcr.io/pnx-si/geonature-frontend:develop" -GDS_GEONATURE_FRONTEND_HOST="${HOST}:${GDS_HTTP_PORT}" -GDS_GEONATURE_FRONTEND_PROTOCOL="http" -GDS_GEONATURE_FRONTEND_PREFIX="/geonature" +GEONATURE_FRONTEND_IMAGE="ghcr.io/pnx-si/geonature-frontend-extended:latest" +GEONATURE_FRONTEND_HOST="${HOST}:${HTTP_PORT}" +GEONATURE_FRONTEND_PROTOCOL="${BASE_PROTOCOL}" +GEONATURE_FRONTEND_PREFIX="/geonature" diff --git a/.env.prod b/.env.prod index d5f49cf..aef0e2c 100644 --- a/.env.prod +++ b/.env.prod @@ -1,34 +1,36 @@ +BASE_PROTOCOL="http" +HOST="example.com" + +HTTP_PORT=80 +HTTPS_PORT=443 + POSTGRES_USER="geonatadmin" POSTGRES_PASSWORD="geonatpasswd" POSTGRES_HOST="postgres" POSTGRES_DB="geonature2db" -GDS_HTTP_PORT=80 -GDS_HTTPS_PORT=443 - -BASE_PROTOCOL="http" -HOST="localhost" +USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:latest" +USERSHUB_HOST="${HOST}" +USERSHUB_PROTOCOL="${BASE_PROTOCOL}" +USERSHUB_DOMAIN="${HOST}" +USERSHUB_PREFIX="/usershub" +USERSHUB_SECRET_KEY="change me" -GDS_USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:latest" -GDS_USERSHUB_HOST="${HOST}" -GDS_USERSHUB_PROTOCOL="${BASE_PROTOCOL}" -GDS_USERSHUB_DOMAIN="${HOST}" -GDS_USERSHUB_PREFIX="/usershub" +TAXHUB_IMAGE="ghcr.io/pnx-si/taxhub:latest" +TAXHUB_DOMAIN="${HOST}" +TAXHUB_PROTOCOL="${BASE_PROTOCOL}" +TAXHUB_HOST="${HOST}" +TAXHUB_PREFIX="/taxhub" +TAXHUB_API_PREFIX="${TAXHUB_PREFIX}/api" -GDS_TAXHUB_IMAGE="ghcr.io/pnx-si/taxhub:latest" -GDS_TAXHUB_DOMAIN="${HOST}" -GDS_TAXHUB_HOST="${HOST}" -GDS_TAXHUB_PREFIX="/taxhub" -GDS_TAXHUB_API_PREFIX="${GDS_TAXHUB_PREFIX}/api" -GDS_TAXHUB_PROTOCOL="${BASE_PROTOCOL}" +GEONATURE_DOMAIN="${HOST}" -GDS_GEONATURE_DOMAIN="${HOST}" -GDS_GEONATURE_BACKEND_IMAGE="ghcr.io/pnx-si/geonature-backend:latest" -GDS_GEONATURE_BACKEND_HOST="${HOST}" -GDS_GEONATURE_BACKEND_PREFIX="/geonature/api" -GDS_GEONATURE_BACKEND_PROTOCOL="${BASE_PROTOCOL}" +GEONATURE_BACKEND_IMAGE="ghcr.io/pnx-si/geonature-backend:latest" +GEONATURE_BACKEND_HOST="${HOST}" +GEONATURE_BACKEND_PREFIX="/geonature/api" +GEONATURE_BACKEND_PROTOCOL="${BASE_PROTOCOL}" -GDS_GEONATURE_FRONTEND_PROTOCOL="${BASE_PROTOCOL}" -GDS_GEONATURE_FRONTEND_HOST="${HOST}" -GDS_GEONATURE_FRONTEND_PREFIX="/geonature" -GDS_GEONATURE_FRONTEND_IMAGE="ghcr.io/pnx-si/geonature-frontend:latest" +GEONATURE_FRONTEND_IMAGE="ghcr.io/pnx-si/geonature-frontend:latest" +GEONATURE_FRONTEND_PROTOCOL="${BASE_PROTOCOL}" +GEONATURE_FRONTEND_HOST="${HOST}" +GEONATURE_FRONTEND_PREFIX="/geonature" diff --git a/.env.prod.swp b/.env.prod.swp new file mode 100644 index 0000000000000000000000000000000000000000..b45e230bb3398ffc7c6b69c6a7f7353fd3f84d68 GIT binary patch literal 12288 zcmeI2zi!h|6o+q_5cCg%7idk_B&DrTi

+$1WEE!&|*4AyOYn*?3U2@t zLwN+47~la|c>q{|2Y`W%5q_>?H%(o#uz-%GPgc%7@jd6e*F%)Mvv8-jIlG!)V7RU@ z_WaT>`#ZDQy~h(wbUPvnkGq;(zQ=ucTpD{4J+NT&kQY2>KNoZg72(!-*!M-Q>^2_= zKNkppuhSGkAupW0yyv_2*r!qg86X2=4fMm^+{#pAY4OJKtA1UYo4t0mG4^YeKnBPF z86X2>fDDiUGC&5%!2e?)^d{I-v~yw5(){2)F>)V#q#GF^17v^??Q&-h!9l2yB6yU=n;m9iPDwxDTozs!akjU>eXx2FL&zAOmE8 z43GgbKnBRb-!M?AC~93c8@ghx>uTLp>gBT$OVgG0+ICSYw1n#%AK#T&Mp{)h%%U`Z z5Zw$^@U9Q#(6haw0i zHdIwfUfV!7=?s6K@+5n-(*pN8!@VS#=Qf)pj4OVJ;{bGa?PYaSuGNQBGE?5JHcFPP z)zZb7KNtk#)j5m{Jr%=>g?zu=-;t6Bj8vUwpT8`Flrtp_;@Mrsvz{zV!%%c1YQRv| zbj7qbl)FW#+2&45%=U!D((!bs^>HvfIIcV$J5xeBlI)_aHBOU8T2JHI9VGLg^q^r^ zS9Ha&$|Y>c8qj3J*i!X!@=cEi!9#l}Au1;s /tmp/docker_compose.log & - - - name: test geonature frontend response - uses: nick-fields/retry@v2 - with: - timeout_seconds: 60 - max_attempts: 10 - retry_wait_seconds: 20 - command: | - url_test="http://localhost:8081/geonature" - res=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "${url_test}") - echo $res - [ "$res" = "200" ] || [ "$res" = "301" ] && exit 0 || exit 1 - - - name: Test geonature backend response - uses: nick-fields/retry@v2 - with: - timeout_seconds: 60 - max_attempts: 15 - retry_wait_seconds: 20 - command: | - url_test="http://localhost:8081/geonature/api/gn_commons/config" - res=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "${url_test}") - echo $res - [ "$res" = "200" ] || [ "$res" = "301" ] && exit 0 || exit 1 - - - name: Test usershub response - uses: nick-fields/retry@v2 - with: - timeout_seconds: 60 - max_attempts: 3 - retry_wait_seconds: 5 - command: | - url_test="http://localhost:8081/usershub/login" - res=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "${url_test}") - echo $res - [ "$res" = "200" ] || [ "$res" = "301" ] && exit 0 || exit 1 - - - name: Test taxhub response - uses: nick-fields/retry@v2 - with: - timeout_seconds: 60 - max_attempts: 3 - retry_wait_seconds: 5 - command: | - url_test="http://localhost:8081/taxhub/" - res=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "${url_test}") - echo $res - [ "$res" = "200" ] || [ "$res" = "301" ] && exit 0 || exit 1 - - - name: Log if fail - if: ${{ failure() }} - run: | - cat /tmp/docker_compose.log - docker compose ps - - backend: name: Build geonature docker images for backend if: ${{ github.event_name != 'pull_request' }} runs-on: ubuntu-latest - needs: tests steps: - name: Checkout uses: actions/checkout@v3 with: submodules: True - - name: Git GeoNature Sumbodule Update - run: | - git submodule init - git submodule update - working-directory: sources/GeoNature - - - name: Set Environnement variables - run: | - scripts/init_env.sh >> $GITHUB_ENV - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -132,58 +34,34 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and export backend app image - uses: docker/build-push-action@v4 - with: - context: ./sources/GeoNature - file: ./sources/GeoNature/backend/Dockerfile - tags: "${{env.GN_BACKEND_TAGS}}" - push: true - target: prod - - - name: Build and export backend wheels image - uses: docker/build-push-action@v4 + - name: Generate image metadata + id: meta + uses: docker/metadata-action@v4 with: - context: ./sources/GeoNature - file: ./sources/GeoNature/backend/Dockerfile - tags: "${{env.GN_BACKEND_TAGS}}-wheels" - push: true - target: wheels + images: ghcr.io/${{ github.repository_owner }}/geonature-backend-extra - - name: Build and export backend app + 4 modules + - name: Build and export image uses: docker/build-push-action@v4 with: context: . file: ./build/Dockerfile-geonature-backend - tags: "${{env.GN_BACKEND_4M_TAGS}}" - labels: | - org.opencontainers.image.title=Application GeoNature + 4 modules principaux - org.opencontainers.image.description=${{env.GN_4M_DESCRIPTION}} - ${{env.GN_LABELS}} - push: true - build-args: GDS_GEONATURE_BACKEND_IMAGE=${{env.GN_BACKEND_IMAGE}} + target: prod-extra + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + env: + GEONATURE_FRONTEND_IMAGE: ghcr.io/pnx-si/geonature-backend frontend: - name: Build geonature docker images for frontend + name: Build geonature docker image for frontend if: ${{ github.event_name != 'pull_request' }} runs-on: ubuntu-latest - needs: tests steps: - name: Checkout uses: actions/checkout@v3 with: submodules: True - - name: Git GeoNature Sumbodule Update - run: | - git submodule init - git submodule update - working-directory: ./sources/GeoNature - - - name: Set Environnement variables - run: | - scripts/init_env.sh >> $GITHUB_ENV - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -195,38 +73,20 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and export frontend source - uses: docker/build-push-action@v4 - with: - context: ./sources/GeoNature - file: ./sources/GeoNature/frontend/Dockerfile - target: source - tags: "${{env.GN_FRONTEND_TAGS}}-source" - push: true - - - name: Build and export frontend nginx - uses: docker/build-push-action@v4 - with: - context: ./sources/GeoNature - file: ./sources/GeoNature/frontend/Dockerfile - target: prod-base - tags: "${{env.GN_FRONTEND_TAGS}}-nginx" - push: true - - - name: Build and export frontend app image - uses: docker/build-push-action@v4 + - name: Generate image metadata + id: meta + uses: docker/metadata-action@v4 with: - context: ./sources/GeoNature - file: ./sources/GeoNature/frontend/Dockerfile - tags: "${{env.GN_FRONTEND_TAGS}}" - push: true - target: prod + images: ghcr.io/${{ github.repository_owner }}/geonature-backend-extra - - name: Build and export frontend + 4 modules + - name: Build and export image uses: docker/build-push-action@v4 with: context: . file: ./build/Dockerfile-geonature-frontend - tags: "${{env.GN_FRONTEND_4M_TAGS}}" - build-args: GDS_GEONATURE_FRONTEND_IMAGE=${{env.GN_FRONTEND_IMAGE}} - push: true + target: prod-extra + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + env: + GEONATURE_FRONTEND_IMAGE: ghcr.io/pnx-si/geonature-frontend diff --git a/.gitignore b/.gitignore index c3fe98e..daa140d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ .env -data/apps/*/config/* -data/apps/taxhub/static/* -data/apps/atlas/custom/* -data/apps/geonature/media/* -data/db/* +config/* +data/taxhub/static/* +data/geonature/media/* !data/**/.gitkeep !data/**/*.sample +*.swp diff --git a/db/add-extensions.sql b/assets/postgres/initdb/add-extensions.sql similarity index 65% rename from db/add-extensions.sql rename to assets/postgres/initdb/add-extensions.sql index 8782cb6..bb8634b 100644 --- a/db/add-extensions.sql +++ b/assets/postgres/initdb/add-extensions.sql @@ -1,5 +1,5 @@ -CREATE EXTENSION IF NOT EXISTS "postgis"; -CREATE EXTENSION IF NOT EXISTS "postgis_raster"; +-- Note: postgis & postgis_raster are alreday created in postgis docker image + CREATE EXTENSION IF NOT EXISTS "hstore"; CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE EXTENSION IF NOT EXISTS "pg_trgm"; diff --git a/build/Dockerfile-geonature-backend b/build/Dockerfile-geonature-backend index 1036f1f..0151723 100644 --- a/build/Dockerfile-geonature-backend +++ b/build/Dockerfile-geonature-backend @@ -1,6 +1,6 @@ -ARG GDS_GEONATURE_BACKEND_IMAGE +ARG GEONATURE_BACKEND_IMAGE -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 \ @@ -27,7 +27,7 @@ WORKDIR /build/ COPY ./sources/gn_module_monitoring . RUN python setup.py bdist_wheel -FROM ${GDS_GEONATURE_BACKEND_IMAGE}-wheels AS prod-extra +FROM ${GEONATURE_BACKEND_IMAGE}-wheels AS prod-extra WORKDIR /dist/geonature RUN --mount=type=cache,target=/var/cache/apt \ diff --git a/build/Dockerfile-geonature-frontend b/build/Dockerfile-geonature-frontend index 3ea1a32..937b134 100644 --- a/build/Dockerfile-geonature-frontend +++ b/build/Dockerfile-geonature-frontend @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1.2 -ARG GDS_GEONATURE_FRONTEND_IMAGE -FROM ${GDS_GEONATURE_FRONTEND_IMAGE}-source AS source-extra +ARG GEONATURE_FRONTEND_IMAGE +FROM ${GEONATURE_FRONTEND_IMAGE}-source AS source-extra WORKDIR /build/external_modules/import COPY ./sources/gn_module_import/frontend/ . @@ -28,6 +28,6 @@ FROM source-extra AS build-extra WORKDIR /build/ RUN npm run build -FROM ${GDS_GEONATURE_FRONTEND_IMAGE}-nginx AS prod-extra +FROM ${GEONATURE_FRONTEND_IMAGE}-nginx AS prod-extra COPY --from=build-extra /build/dist /usr/share/nginx/html diff --git a/data/apps/atlas/config/.gitkeep b/config/geonature/.gitkeep similarity index 100% rename from data/apps/atlas/config/.gitkeep rename to config/geonature/.gitkeep diff --git a/data/apps/atlas/custom/.gitkeep b/config/taxhub/.gitkeep similarity index 100% rename from data/apps/atlas/custom/.gitkeep rename to config/taxhub/.gitkeep diff --git a/data/apps/geonature/config/.gitkeep b/config/usershub/.gitkeep similarity index 100% rename from data/apps/geonature/config/.gitkeep rename to config/usershub/.gitkeep diff --git a/data/apps/atlas/config/config.py.sample b/data/apps/atlas/config/config.py.sample deleted file mode 100644 index 3541ed5..0000000 --- a/data/apps/atlas/config/config.py.sample +++ /dev/null @@ -1,105 +0,0 @@ -# -*- coding:utf-8 -*- - -############################## -## Fichier de configuration ## -############################## - -# Connexion de l'application à la BDD -# Remplacer user, monpassachanger, IPADRESSE (localhost si la BDD est sur le même serveur que l'application), -# eventuellement le port de la BDD et le nom de la BDD avec l'utilisateur qui a des droits de lecture sur les vues de l'atlas (user_pg dans settings.ini) -database_connection = "postgresql://user:monpassachanger@IPADRESSE:5432/databaseName" - -# Recharger automatiquement les templates -TEMPLATES_AUTO_RELOAD = False - -################################# -################################# -### Customisation application ### -################################# -################################# - -# Nom de la structure -STRUCTURE = "Nom de la structure" - -# Nom de l'application -NOM_APPLICATION = "Nom de l application" - -# URL de l'application depuis la racine du domaine -# ex "/atlas" pour une URL: http://mon-domaine/atlas OU "" si l'application est accessible à la racine du domaine -URL_APPLICATION = "" - -################################# -################################# -###### Modules activation ####### -################################# -################################# - -# Enable organism module : organism sheet + organism participation on species sheet -ORGANISM_MODULE = False - -########################### -###### Multilingual ####### -########################### - -# Default language, also used when multilingual is disabled -DEFAULT_LANGUAGE = 'fr' - -# Activate multilingual -MULTILINGUAL = False - -# Available languages -# Don't delete, even if you disable MULTILINGUAL -# You need to add your own default language (DEFAULT_LANGUAGE) here if it's not present -# Check documentation to add another language -LANGUAGES = { - 'en': { - 'name' : 'English', - 'flag_icon' : 'flag-icon-gb', - 'months' : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] - }, - 'fr': { - 'name' : 'Français', - 'flag_icon' : 'flag-icon-fr', - 'months' : ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Decembre'] - }, - 'it': { - 'name' : 'Italiano', - 'flag_icon' : 'flag-icon-it', - 'months' : ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'] - } -} - -########################### -########################### -###### Cartographie ####### -########################### -########################### - -# Configuration des cartes (centre du territoire, couches CARTE et ORTHO, échelle par défaut...) -MAP = { - 'LAT_LONG': [44.7952, 6.2287], - 'FIRST_MAP': { - 'url' : '//{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', - 'attribution' : '© OpenStreetMap', - 'tileName' : 'OSM' - }, - 'SECOND_MAP' : {'url' :'//a.tile.opentopomap.org/{z}/{x}/{y}.png', - 'attribution' : '© OpenStreetMap-contributors, SRTM | Style: © OpenTopoMap (CC-BY-SA)', - 'tileName' : 'OTM' - }, - 'ZOOM' : 10, - # Pas du slider sur les annees d'observations: 1 = pas de 1 an sur le slider - 'STEP': 1, - # Couleur et épaisseur des limites du territoire - 'BORDERS_COLOR': '#000000', - 'BORDERS_WEIGHT': 3, - 'ENABLE_SLIDER': True -} - -########################### -########################### -#### Security Config ##### -########################### -########################### - -SECRET_KEY = 'INSERT_A_RANDOM_SECRET_KEY' diff --git a/data/apps/usershub/config/.gitkeep b/data/apps/usershub/config/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/data/db/.gitkeep b/data/db/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/data/apps/geonature/media/.gitkeep b/data/geonature/media/.gitkeep similarity index 100% rename from data/apps/geonature/media/.gitkeep rename to data/geonature/media/.gitkeep diff --git a/data/apps/taxhub/config/.gitkeep b/data/taxhub/static/.gitkeep similarity index 100% rename from data/apps/taxhub/config/.gitkeep rename to data/taxhub/static/.gitkeep diff --git a/data/apps/taxhub/static/.gitkeep b/data/traefik/certs/.gitkeep similarity index 100% rename from data/apps/taxhub/static/.gitkeep rename to data/traefik/certs/.gitkeep diff --git a/docker-compose.atlas.yml b/docker-compose.atlas.yml deleted file mode 100644 index 389e329..0000000 --- a/docker-compose.atlas.yml +++ /dev/null @@ -1,30 +0,0 @@ -services: - atlas: - image: ${GDS_ATLAS_IMAGE} - depends_on: - - postgres - - geonature-backend - environment: - - POSTGRES_DB=${POSTGRES_DB} - - POSTGRES_USER=${POSTGRES_USER} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - - POSTGRES_HOST=${POSTGRES_HOST:-postgres} - - POSTGRES_PORT= ${POSTGRES_PORT:-5432} - - ATLAS_ALTITUDES=${ATLAS_ALTITUDES:-(0 500 1000 1500 2000 2500 3000 3500 4000)} - - ATLAS_TYPE_TERRITOIRE=${ATLAS_TYPE_TERRITOIRE:-'PEC'} - - ATLAS_TYPE_MAILLE=${ATLAS_TYPE_MAILLE:-'M1'} - - ATLAS_INSTALL_SCHEMA=${ATLAS_INSTALL_SCHEMA:-false} - - ATLAS_RESET_SCHEMA=${ATLAS_RESET_SCHEMA:-false} - - ATLAS_URL_APPLICATION="${GDS_ATLAS_PROTOCOL:-http}://${GDS_ATLAS_HOST}${GDS_ATLAS_PREFIX:-/atlas}" - - ATLAS_APPLICATION_ROOT="${GDS_ATLAS_PREFIX:-/atlas}" - - ATLAS_REMOTE_MEDIAS_URL="${GDS_TAXHUB_PROTOCOL:-http}://${GDS_TAXHUB_HOST}${GDS_TAXHUB_PREFIX:-/taxhub}/" - - ATLAS_TAXHUB_URL="${GDS_TAXHUB_PROTOCOL:-http}://${GDS_TAXHUB_HOST}${GDS_TAXHUB_PREFIX:-/taxhub}" - - ATLAS_REDIMENSIONNEMENT_IMAGE=${ATLAS_REDIMENSIONNEMENT_IMAGE:-true} - - ATLAS_database_connection=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT:-5432}/${POSTGRES_DB} - volumes: - - ${GDS_GEONATURE_ATLAS_CONFIG_DIRECTORY:-./data/apps/atlas/config}:/dist/config - - ${GDS_GEONATURE_ATLAS_CUSTOM_DIRECTORY:-./data/apps/atlas/custom}:/dist/static/custom - labels: - - "traefik.enable=true" - - "traefik.http.routers.atlas.rule=Host(`${GDS_ATLAS_DOMAIN}`) && PathPrefix(`${GDS_ATLAS_PREFIX:-/atlas}`)" - - "traefik.http.routers.atlas.entrypoints=web" \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml deleted file mode 100644 index 3e7c029..0000000 --- a/docker-compose.override.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: "3.9" - -services: - traefik: - command: - - --api.insecure=true - - --providers.docker=true - - --providers.docker.exposedbydefault=false - - --entrypoints.web.address=:80 - ports: - # - ${TRAEFIK_PORT:-8888}:80 - - ${TRAEFIK_DASHBOARD_PORT:-8889}:8080 - - postgres: - ports: - - ${POSTGRES_EXPOSED_PORT:-5435}:5432 \ No newline at end of file diff --git a/docker-compose.traefik.yml b/docker-compose.traefik.yml deleted file mode 100644 index 80a785a..0000000 --- a/docker-compose.traefik.yml +++ /dev/null @@ -1,13 +0,0 @@ -services: - traefik: - image: traefik:2.9 - command: - - "--providers.docker=true" - - "--providers.docker.exposedbydefault=false" - - "--entrypoints.web.address=:80" - - "--entrypoints.websecure.address=:443" - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro - ports: - - ${GDS_HTTP_PORT:-80}:80 - - ${GDS_HTTPS_PORT:-443}:443 diff --git a/docker-compose.yml b/docker-compose.yml index 1cfe6e1..9a0b743 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,14 +2,17 @@ version: "3.9" x-defaults: &defaults user: ${UID:-1000}:${GID:-1000} + environment: + - http_proxy=${HTTP_PROXY:-} + - https_proxy=${HTTPS_PROXY:-} x-geonature-backend-defaults: &geonature-backend-defaults <<: *defaults environment: - GEONATURE_SQLALCHEMY_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT:-5432}/${POSTGRES_DB} - - GEONATURE_URL_APPLICATION="${GDS_GEONATURE_FRONTEND_PROTOCOL}://${GDS_GEONATURE_FRONTEND_HOST}${GDS_GEONATURE_FRONTEND_PREFIX:-}" - - GEONATURE_API_ENDPOINT="${GDS_GEONATURE_BACKEND_PROTOCOL}://${GDS_GEONATURE_BACKEND_HOST}${GDS_GEONATURE_BACKEND_PREFIX:-/}" - - GEONATURE_API_TAXHUB="${GDS_TAXHUB_PROTOCOL}://${GDS_TAXHUB_HOST}${GDS_TAXHUB_API_PREFIX}" + - GEONATURE_URL_APPLICATION="${GEONATURE_FRONTEND_PROTOCOL}://${GEONATURE_FRONTEND_HOST}${GEONATURE_FRONTEND_PREFIX:-}" + - GEONATURE_API_ENDPOINT="${GEONATURE_BACKEND_PROTOCOL}://${GEONATURE_BACKEND_HOST}${GEONATURE_BACKEND_PREFIX:-/}" + - GEONATURE_API_TAXHUB="${TAXHUB_PROTOCOL}://${TAXHUB_HOST}${TAXHUB_API_PREFIX}" - GEONATURE_CONFIG_FILE=${GEONATURE_CONFIG_FILE:-/dist/config/geonature_config.toml} - GEONATURE_STATIC_FOLDER=${GEONATURE_STATIC_FOLDER:-/dist/static} - GEONATURE_CUSTOM_STATIC_FOLDER=${GEONATURE_CUSTOM_STATIC_FOLDER:-/dist/custom} @@ -31,31 +34,59 @@ x-geonature-backend-defaults: &geonature-backend-defaults - taxhub_samples=${GEONATURE_INSTALL_TAXHUB_SAMPLES:-true} services: + traefik: + image: traefik:2.10.4 + command: + - "--providers.docker=true" + - "--providers.docker.exposedbydefault=false" + - "--entrypoints.web.address=:80" + - "--entrypoints.websecure.address=:443" + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - ./data/traefik/certs:/certs + ports: + - ${HTTP_PORT:-80}:80 + - ${HTTPS_PORT:-443}:443 + redis: image: ${REDIS_IMAGE:-redis:7-alpine} volumes: - redis:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 postgres: - image: ${POSTGRES_IMAGE:-postgis/postgis:13-3.2} + image: ${POSTGRES_IMAGE:-postgis/postgis:15-3.4} environment: - POSTGRES_DB=${POSTGRES_DB} - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_PORT=${POSTGRES_PORT:-5432} volumes: - - ${POSTGRES_INIT_DB_DIR-./sources/GeoNature/install/assets/db}:/docker-entrypoint-initdb.d/ - - ${GDS_POSTGRES_DIRECTORY:-./data/db/postgres}:/var/lib/postgresql/data + - ./assets/postgres/initdb:/docker-entrypoint-initdb.d/ + - postgres:/var/lib/postgresql/data + healthcheck: + # during db init, postgres is not listening on localhost so this avoid false healthy status + test: ["CMD", "pg_isready", "-d", "${POSTGRES_DB}", "-U", "${POSTGRES_USER}", "-h", "localhost"] + interval: 10s + timeout: 5s + retries: 5 + usershub: - <<: *geonature-backend-defaults - image: ${GDS_USERSHUB_IMAGE:-ghcr.io/pnx-si/usershub:latest} + <<: *defaults + image: ${USERSHUB_IMAGE} depends_on: - - postgres + postgres: + condition: service_healthy volumes: - - ${GDS_USERSHUB_CONFIG_DIRECTORY:-./data/apps/usershub/config}:/dist/config/ + - ${USERSHUB_CONFIG_DIRECTORY:-./config/usershub}:/dist/config/ environment: - - USERSHUB_URL_APPLICATION="${GDS_USERSHUB_PROTOCOL:-http}://${GDS_USERSHUB_HOST}${GDS_USERSHUB_PREFIX:-/usershub}" + - USERSHUB_URL_APPLICATION="${USERSHUB_PROTOCOL}://${USERSHUB_HOST}${USERSHUB_PREFIX}" - USERSHUB_SQLALCHEMY_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT:-5432}/${POSTGRES_DB} - - USERSHUB_SECRET_KEY=${USERSHUB_SECRET_KEY:-ABCDEFGH123} + - USERSHUB_SECRET_KEY=${USERSHUB_SECRET_KEY} - USERSHUB_SETTINGS=${USERSHUB_SETTINGS:-/dist/config/config.py} - USERSHUB_ACTIVATE_APP=${USERSHUB_ACTIVATE_APP:-true} - USERSHUB_ACTIVATE_API=${USERSHUB_ACTIVATE_API:-true} @@ -63,74 +94,66 @@ services: - PYTHONPATH=/dist/config labels: - "traefik.enable=true" - - "traefik.http.routers.usershub.rule=Host(`${GDS_USERSHUB_DOMAIN}`) && PathPrefix(`${GDS_USERSHUB_PREFIX:-/usershub}`)" + - "traefik.http.routers.usershub.rule=Host(`${USERSHUB_DOMAIN}`) && PathPrefix(`${USERSHUB_PREFIX:-/usershub}`)" - "traefik.http.routers.usershub.entrypoints=web" taxhub: - <<: *geonature-backend-defaults - image: ${GDS_TAXHUB_IMAGE:-ghcr.io/pnx-si/taxhub:latest} + <<: *defaults + image: ${TAXHUB_IMAGE} depends_on: - - postgres + postgres: + condition: service_healthy volumes: - - ${GDS_TAXHUB_CONFIG_DIRECTORY:-./data/apps/taxhub/config}:/dist/config - - ${GDS_TAXHUB_STATIC_DIRECTORY:-./data/apps/taxhub/static}:/dist/static + - ${TAXHUB_CONFIG_DIRECTORY:-./config/taxhub/config}:/dist/config + - ${TAXHUB_STATIC_DIRECTORY:-./data/taxhub/static}:/dist/static environment: - - TAXHUB_APPLICATION_ROOT="${GDS_TAXHUB_PREFIX:-/taxhub}" + - TAXHUB_APPLICATION_ROOT="${TAXHUB_PREFIX}" - TAXHUB_SQLALCHEMY_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT:-5432}/${POSTGRES_DB} - TAXHUB_SETTINGS=${TAXHUB_SETTINGS:-config.py} - PYTHONPATH=/dist/config labels: - "traefik.enable=true" - - "traefik.http.routers.taxhub.rule=Host(`${GDS_TAXHUB_DOMAIN}`) && PathPrefix(`${GDS_TAXHUB_PREFIX:-/taxhub}`)" + - "traefik.http.routers.taxhub.rule=Host(`${TAXHUB_DOMAIN}`) && PathPrefix(`${TAXHUB_PREFIX:-/taxhub}`)" - "traefik.http.routers.taxhub.entrypoints=web" geonature-worker: <<: *geonature-backend-defaults - image: ${GDS_GEONATURE_BACKEND_IMAGE:-ghcr.io/pnx-si/geonature-backend:latest} + image: ${GEONATURE_BACKEND_IMAGE} depends_on: - - redis - - postgres + redis: + condition: service_healthy + postgres: + condition: service_healthy volumes: - ${CONFIG_DIRECTORY:-./data/apps/geonature/config}:/dist/config/ command: celery -A geonature.celery_app:app worker geonature-backend: <<: *geonature-backend-defaults - image: ${GDS_GEONATURE_BACKEND_IMAGE:-ghcr.io/pnx-si/geonature-backend:latest} + image: ${GEONATURE_BACKEND_IMAGE} depends_on: - - redis - - postgres + redis: + condition: service_healthy + postgres: + condition: service_healthy volumes: - - ${GDS_GEONATURE_CONFIG_DIRECTORY:-./data/apps/geonature/config}:/dist/config - - ${GDS_GEONATURE_MEDIA_DIRECTORY:-./data/apps/geonature/media}:/dist/media + - ${GEONATURE_CONFIG_DIRECTORY:-./data/apps/geonature/config}:/dist/config + - ${GEONATURE_MEDIA_DIRECTORY:-./data/apps/geonature/media}:/dist/media labels: - "traefik.enable=true" - - "traefik.http.routers.geonature-backend.rule=Host(`${GDS_GEONATURE_DOMAIN}`) && PathPrefix(`${GDS_GEONATURE_BACKEND_PREFIX:-/geonature/api}`)" + - "traefik.http.routers.geonature-backend.rule=Host(`${GEONATURE_DOMAIN}`) && PathPrefix(`${GEONATURE_BACKEND_PREFIX:-/geonature/api}`)" - "traefik.http.routers.geonature-backend.entrypoints=web" geonature-frontend: - image: ${GDS_GEONATURE_FRONTEND_IMAGE:-ghcr.io/pnx-si/geonature-frontend:latest} + image: ${GEONATURE_FRONTEND_IMAGE} environment: - - NGINX_LOCATION=${GDS_GEONATURE_FRONTEND_PREFIX:-/} - - API_ENDPOINT="${GDS_GEONATURE_BACKEND_PROTOCOL}://${GDS_GEONATURE_BACKEND_HOST}${GDS_GEONATURE_BACKEND_PREFIX:-/}" + - NGINX_LOCATION=${GEONATURE_FRONTEND_PREFIX} + - API_ENDPOINT="${GEONATURE_BACKEND_PROTOCOL}://${GEONATURE_BACKEND_HOST}${GEONATURE_BACKEND_PREFIX}" labels: - "traefik.enable=true" - - "traefik.http.routers.geonature.rule=Host(`${GDS_GEONATURE_DOMAIN}`) && PathPrefix(`${GDS_GEONATURE_FRONTEND_PREFIX:-/}`)" + - "traefik.http.routers.geonature.rule=Host(`${GEONATURE_DOMAIN}`) && PathPrefix(`${GEONATURE_FRONTEND_PREFIX:-/}`)" - "traefik.http.routers.geonature.entrypoints=web" - traefik: - image: traefik:2.9 - command: - - "--providers.docker=true" - - "--providers.docker.exposedbydefault=false" - - "--entrypoints.web.address=:80" - - "--entrypoints.websecure.address=:443" - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro - ports: - - ${GDS_HTTP_PORT:-80}:80 - - ${GDS_HTTPS_PORT:-443}:443 - volumes: redis: - postgres: \ No newline at end of file + postgres: