version: "3.8"

services:
  odk-db:
    image: postgres:15-alpine
    container_name: odk-postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: odk
      POSTGRES_USER: odk
      POSTGRES_PASSWORD: odk
    volumes:
      - odk_postgres_data:/var/lib/postgresql/data
    networks:
      - odk-internal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U odk"]
      interval: 10s
      timeout: 5s
      retries: 5

  odk-backend:
    image: "ghcr.io/getodk/central-backend:2024.3.0"
    container_name: odk-backend
    restart: unless-stopped
    depends_on:
      odk-db:
        condition: service_healthy
    environment:
      - DOMAIN=odk.digitribe.fr
      - HTTPS_PORT=443
      - SYSADMIN_EMAIL=admin@digitribe.fr
      - DB_HOST=odk-db
      - DB_PORT=5432
      - DB_NAME=odk
      - DB_USER=odk
      - DB_PASSWORD=odk
    volumes:
      - odk_backend_data:/data
    networks:
      - odk-internal
      - smartcity-shared
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.odk.rule=Host(`odk.digitribe.fr`)"
      - "traefik.http.routers.odk.entrypoints=websecure"
      - "traefik.http.routers.odk.tls.certresolver=letsencrypt"
      - "traefik.http.services.odk.loadbalancer.server.port=8383"
      - "traefik.docker.network=smartcity-shared"

  odk-frontend:
    image: "ghcr.io/getodk/central-frontend:2024.3.0"
    container_name: odk-frontend
    restart: unless-stopped
    depends_on:
      - odk-backend
    environment:
      - DOMAIN=odk.digitribe.fr
    networks:
      - odk-internal
    labels:
      - "traefik.enable=false"

  odk-pyxform:
    image: "ghcr.io/getodk/central-pyxform:v4.4.1"
    container_name: odk-pyxform
    restart: unless-stopped
    networks:
      - odk-internal

volumes:
  odk_postgres_data:
  odk_backend_data:

networks:
  odk-internal:
    internal: true
  smartcity-shared:
    external: true
