---
version: "3.5"

volumes:
  geocontrib_db:
  geocontrib_media:
  geocontrib_static:
  geocontrib_config_front:

services:
  geocontrib: &geocontrib
    restart: unless-stopped
    image: neogeo/geocontrib:${GEOCONTRIB_VERSION}
    environment:
      - SECRET_KEY=${SECRET}
      - ALLOWED_HOSTS=${DOMAINS:-127.0.0.1}
      - DEBUG=${DEBUG:-False}
      - TIME_ZONE=Europe/Paris
      - LOG_LEVEL=${LOG_LEVEL:-INFO}
      - TIME_SLEEP=5
      - BASE_URL=${BASE_URL}
      - DB_USER=geocontrib
      - DB_PWD=geocontrib
      - DB_NAME=geocontrib
      - DB_HOST=geocontrib-db
      - DB_PORT=5432
      - APP_ADMIN_USER=admin
      - APP_ADMIN_PWD=admin
      - APP_ADMIN_EMAIL=admin@acme.com
      - EMAIL_BACKEND=${EMAIL_BACKEND}
      - EMAIL_HOST=${EMAIL_HOST}
      - EMAIL_PORT=${EMAIL_PORT}
      - EMAIL_USE_TLS=${EMAIL_USE_TLS}
      - EMAIL_HOST_USER=${EMAIL_HOST_USER}
      - EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD}
      - DEFAULT_FROM_EMAIL=${DEFAULT_FROM_EMAIL}
      - DEFAULT_SENDING_FREQUENCY=${DEFAULT_SENDING_FREQUENCY:-instantly}
      - APPLICATION_NAME=${APPLICATION_NAME:-Géocontrib}
      - APPLICATION_ABSTRACT=${APPLICATION_ABSTRACT:-Application Géocontrib}
      - MAGIC_IS_AVAILABLE=${MAGIC_IS_AVAILABLE:-True}
      - URL_PREFIX=geocontrib/
      - LOGO_PATH=${LOGO_PATH:-/geocontrib/img/logo-neogeo-circle.png}
      - DISPLAY_FORBIDDEN_PROJECTS=${DISPLAY_FORBIDDEN_PROJECTS:-"true"}
      - LOG_URL=${LOG_URL}
      - HIDE_USER_CREATION_BUTTON=${HIDE_USER_CREATION_BUTTON}
      - LOGOUT_HIDDEN=${LOGOUT_HIDDEN}


    volumes:
      - geocontrib_config_front:/home/apprunner/geocontrib_app/config_front
      - geocontrib_media:/home/apprunner/geocontrib_app/media
      - geocontrib_static:/home/apprunner/geocontrib_app/static
    depends_on:
      - "geocontrib-db"
  celery:
      <<: *geocontrib
      command: src/docker/geocontrib/start_celery.sh

  celery-beat:
      <<: *geocontrib
      command: src/docker/geocontrib/start_celery_beat.sh

  # ---------------------------------------------------------------- #
  geocontrib-db:
    restart: unless-stopped
    image: postgis/postgis:${POSTGIS_VERSION}
    environment:
      - POSTGRES_USER=geocontrib
      - POSTGRES_PASSWORD=geocontrib
      - POSTGRES_DB=geocontrib
    volumes:
      - geocontrib_db:/var/lib/postgresql/data/
    ports:
      - "${POSTGRES_PORT:-5432}:5432"
  redis:
    image: redis
    restart: unless-stopped
  # ---------------------------------------------------------------- #
  front:
    restart: unless-stopped
    image: neogeo/geocontrib-front:${FRONT_VERSION}
    volumes:
      - geocontrib_config_front:/opt/geocontrib/config/:ro
      - geocontrib_media:/opt/geocontrib/media
      - geocontrib_static:/opt/geocontrib/static
    ports:
      - "${HTTP_PORT:-80}:80"
    depends_on:
      - geocontrib
  # ---------------------------------------------------------------- #
