Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service geonature-atlas #51

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
43 changes: 42 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

# Force mutli files loading for Compose
#COMPOSE_FILE="docker-compose.yml:docker-compose.override.yml"

BASE_PROTOCOL="https" # do not change to http, unless you know how to fix traefik labels

HTTP_PORT=80
Expand All @@ -7,7 +10,7 @@ HTTPS_PORT=443
HOST="localhost"
HOSTPORT="${HOST}" # set to ${HOST}:${HTTPS_PORT} if HTTPS_PORT is different from 443

ACME_EMAIL="" # required for valid https certificates
ACME_EMAIL="<your-email>" # required for valid https certificates

UID=1000 # Change with the value returned by the command `id -u`
GID=1000 # Change with the value returned by the command `id -g`
Expand All @@ -26,6 +29,7 @@ GEONATURE_DB_INSTALL_TAXHUB_SAMPLES=true
POSTGRES_USER="geonatadmin"
POSTGRES_PASSWORD="geonatpasswd"
POSTGRES_HOST="postgres"
POSTGRES_PORT="5432"
POSTGRES_DB="geonature2db"

USERSHUB_IMAGE="ghcr.io/pnx-si/usershub:latest"
Expand All @@ -52,3 +56,40 @@ GEONATURE_FRONTEND_PROTOCOL="${BASE_PROTOCOL}"
GEONATURE_FRONTEND_HOST="${HOST}"
GEONATURE_FRONTEND_HOSTPORT="${HOSTPORT}"
GEONATURE_FRONTEND_PREFIX="/geonature"

# +---------------------------------------------------------------------+
# Extra local env parameters for docker-compose.override.yml
HOSTNAME="<your-host-name>"
TZ="Europe/Paris"
POSTGRES_HOST_PORT="55432"
HOST_USER="<you-host-user-login>"
#ATLAS_IMAGE="ghcr.io/pnx-si/geonature-atlas:1.6.2"
#POSTGRES_IMAGE="postgis/postgis:17-3.5"
# +---------------------------------------------------------------------+
# Atlas compose
ATLAS_HEALTHCHECK_INTERVAL="30s"
# +---------------------------------------------------------------------+
# Atlas URL
ATLAS_PROTOCOL="${BASE_PROTOCOL}"
ATLAS_HOST="${HOST}"
ATLAS_PREFIX="/atlas"
# +---------------------------------------------------------------------+
# Atlas database
# Set to true for install:
ATLAS_INSTALL_SCHEMA="false"
# Set to true for install:
ATLAS_RESET_SCHEMA="false"
# +---------------------------------------------------------------------+
# Atlas settings
ATLAS_SECRET_KEY="<your-secret-key>"
ATLAS_URL_APPLICATION="${ATLAS_HOST}${ATLAS_PREFIX}"
ATLAS_APPLICATION_ROOT="${ATLAS_PREFIX}"
ATLAS_REMOTE_MEDIAS_URL="${HOST}/taxhub"
ATLAS_TAXHUB_URL="${ATLAS_REMOTE_MEDIAS_URL}"
ATLAS_SQLALCHEMY_DATABASE_URI="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
ATLAS_TEMPLATES_AUTO_RELOAD="true"

ATLAS_ALTITUDES="(0 500 1000 1500 2000 2500 3000 3500 4000)"
ATLAS_TYPE_TERRITOIRE="PEC"
ATLAS_TYPE_MAILLE="M1"
ATLAS_REDIMENSIONNEMENT_IMAGE="true"
7 changes: 7 additions & 0 deletions assets/atlas/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# docker healthcheck ATLAS
url_test=http://localhost:8080${ATLAS_APPLICATION_ROOT}/
if [ ! -f /tmp/container_healthy ]; then
curl --noproxy localhost -f "${url_test}" || exit 1
touch /tmp/container_healthy
fi
18 changes: 18 additions & 0 deletions build/atlas/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG ATLAS_IMAGE

FROM ${ATLAS_IMAGE}

ARG UID
ARG GID
ARG HOST_USER

USER root
# Add the group (if not existing) then add the user to the group
RUN id --name --group ${GID} || \
addgroup --gid ${GID} ${HOST_USER} && \
id --name --user ${UID} || \
adduser --gecos GECOS --disabled-password --uid ${UID} --gid ${GID} ${HOST_USER}

#Fix
RUN sed -i "s/:type_territoire/:\'type_territoire\'/g" /dist/data/gn2/atlas_ref_geo.sql && \
sed -i "s/:type_maille/:\'type_maille\'/g" /dist/data/atlas/12.atlas.t_mailles_territoire.sql
34 changes: 34 additions & 0 deletions build/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG POSTGRES_IMAGE

FROM ${POSTGRES_IMAGE:-postgis/postgis:15-3.4}
# See: https://hub.docker.com/r/postgis/postgis
# TODO: build image to add specific optimized config, pg activity utility, vim, bash alias...

ARG TZ

# Change default Postgresql locale
RUN localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8

ENV LANG fr_FR.utf8
ENV TZ ${TZ}

# Install utils
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install -y --quiet --no-install-recommends \
vim htop sudo pg-activity \
&& apt-get -y autoremove \
&& apt-get clean autoclean \
&& rm -fr /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*

# Add /etc/vim/vimrc.local
RUN echo "runtime! defaults.vim" > /etc/vim/vimrc.local \
&& echo "let g:skip_defaults_vim = 1" >> /etc/vim/vimrc.local \
&& echo "set mouse=" >> /etc/vim/vimrc.local

# Uncomment alias from /root/.bashrc
RUN sed -i -r 's/^# (alias|export|eval)/\1/' /root/.bashrc

# Add Pg Activity alias
RUN grep -qxF "alias pga='pg_activity -U ${POSTGRES_USER} -d ${POSTGRES_DB}'" /root/.bashrc \
|| echo "alias pga='pg_activity -U ${POSTGRES_USER} -d ${POSTGRES_DB}'" >> /root/.bashrc
Empty file added config/atlas/.gitkeep
Empty file.
Empty file added data/atlas/custom/.gitkeep
Empty file.
48 changes: 47 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ services:
TAXHUB_SQLALCHEMY_DATABASE_URI: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT:-5432}/${POSTGRES_DB}
TAXHUB_SETTINGS: ${TAXHUB_SETTINGS:-/dist/config/config.py}
TAXHUB_UPLOAD_FOLDER: "medias"
TAXHUB_SQLALCHEMY_TRACK_MODIFICATIONS: False
TAXHUB_SQLALCHEMY_TRACK_MODIFICATIONS: "False"
TAXHUB_COOKIE_EXPIRATION: 3600
TAXHUB_PASS_METHOD: "hash"
labels:
Expand Down Expand Up @@ -193,6 +193,52 @@ services:
- "traefik.http.routers.geonature.entrypoints=websecure"
- "traefik.http.routers.geonature.tls.certResolver=acme-resolver"

geonature-atlas:
<<: *defaults
image: ${ATLAS_IMAGE:-ghcr.io/pnx-si/geonature-atlas:1.6.2}
depends_on:
postgres:
condition: service_healthy
environment:
<<: *env-defaults
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
POSTGRES_HOST: ${POSTGRES_HOST}
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: ${ATLAS_URL_APPLICATION:-${ATLAS_HOST}${ATLAS_PREFIX}}
ATLAS_APPLICATION_ROOT: ${ATLAS_PREFIX}
ATLAS_REMOTE_MEDIAS_URL: ${ATLAS_REMOTE_MEDIAS_URL:-taxhub.${HOST}/}
ATLAS_TAXHUB_URL: ${ATLAS_REMOTE_MEDIAS_URL}
ATLAS_REDIMENSIONNEMENT_IMAGE: ${ATLAS_REDIMENSIONNEMENT_IMAGE:-true}
ATLAS_SECRET_KEY: ${ATLAS_SECRET_KEY}
ATLAS_SQLALCHEMY_DATABASE_URI: ${ATLAS_SQLALCHEMY_DATABASE_URI:-"postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"}
ATLAS_TEMPLATES_AUTO_RELOAD: "true"
volumes:
- ./config/atlas:/dist/config
- ./data/atlas/custom:/dist/static/custom
- ./assets/atlas:/assets
labels:
- "traefik.enable=true"
- "traefik.http.routers.geonature-atlas.rule=Host(`${ATLAS_HOST}`) && PathPrefix(`${ATLAS_PREFIX}`)"
- "traefik.http.routers.geonature-atlas.entrypoints=websecure"
- "traefik.http.routers.geonature-atlas.tls=true"
- "traefik.http.routers.geonature-atlas.tls.certresolver=acme-resolver"
healthcheck:
test: ["CMD-SHELL", "/assets/healthcheck.sh"]
interval: ${ATLAS_HEALTHCHECK_INTERVAL}
timeout: 10s
retries: 20
start_period: 0s
logging:
options:
tag: geonature-atlas

volumes:
redis:
postgres:
3 changes: 3 additions & 0 deletions init-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ fi
if [ ! -f config/taxhub/config.py ]; then
echo SECRET_KEY = \"$(openssl rand -hex 16)\" > config/taxhub/config.py
fi
if [ ! -f config/atlas/config.py ]; then
echo SECRET_KEY = \"$(openssl rand -hex 16)\" > config/atlas/config.py
fi