services:
  database:
    image: iut/pgsql:2025-11
    environment:
      POSTGRES_INITDB_ARGS: "--locale-provider=icu --icu-locale=fr-FR"
      POSTGRES_DB: ${COMPOSE_PROJECT_NAME}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
      POSTGRES_USER: ${COMPOSE_PROJECT_NAME}
    volumes:
      - database_data:/var/lib/postgresql/data:rw
      - ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:Z
      - ./data:/tmp:Z
    ports:
      - 5432:5432
    healthcheck:
      test: ["CMD", "pg_isready", "--username", "${COMPOSE_PROJECT_NAME}", "--dbname", "${COMPOSE_PROJECT_NAME}"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 20s

  superset:
    image: apache/superset:3.1.3
    depends_on:
      database:
        condition: service_healthy
    environment:
      SUPERSET_CONFIG_PATH: /app/pythonpath/superset_config.py
      SUPERSET_SECRET_KEY: ${SUPERSET_SECRET:-YOUR_OWN_RANDOM_GENERATED_SECRET_KEY}
      SUPERSET_LOAD_EXAMPLES: no
    ports:
      - "8088:8088"
    volumes:
      - superset_home:/app/superset_home
      - ./superset_config.py:/app/pythonpath/superset_config.py:Z
    command: >
      sh -c "
      superset db upgrade &&
      superset fab create-admin --username admin --firstname Admin --lastname User --email admin@superset.com --password admin &&
      superset init &&
      superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger
      "

  metabase:
    image: metabase/metabase:v0.56.5.5
    depends_on:
      database:
        condition: service_healthy
    volumes:
      - /dev/urandom:/dev/random:ro
    ports:
      - "3000:3000"
    environment:
      MB_DB_TYPE: postgres
      MB_DB_HOST: ${MB_DB_HOST:-database}
      MB_DB_PORT: 5432
      MB_DB_USER: metabase_user
      MB_DB_PASS: ${DB_ROOT_PASSWORD:-supermotdepasse}
      MB_DB_DBNAME: metabase
      MB_SITE_LOCALE: fr
      MB_ADMIN_EMAIL: etudiant@univ-lorraine.fr
      MB_ANON_TRACKING_ENABLED: false
      MB_CHECK_FOR_UPDATES: false
      MB_NO_SURVEYS: yes
      MB_START_OF_WEEK: monday
      MB_CUSTOM_FORMATTING: '{"type/Temporal":{"time_style":"HH:mm","date_style":"D MMMM, YYYY","date_abbreviate":true},"type/Currency":{"currency":"EUR"},"type/Number":{"number_separators":", "}}'
      MB_EMAIL_SMTP_HOST: mailpit
      MB_EMAIL_SMTP_PORT: 1025
      MB_EMAIL_FROM_ADDRESS: metabase@univ-lorraine.fr

  metabase-init:
    build:
      context: ./metabase
    depends_on:
      - metabase

# CouchDB
# Single-node document database
# https://couchdb.apache.org/
  couchdb:
    image: couchdb:${COUCH_DB_VERSION:-3.5}
    volumes:
      - couchdb_data:/opt/couchdb/data
    ports:
      - "5984:5984"
    environment:
      COUCHDB_USER: ${DB_ROOT_USER:-admin}
      COUCHDB_PASSWORD: ${DB_ROOT_PASSWORD:-!ChangeMe!}

  mongodb:
    image: mongodb/mongodb-community-server:8.0-ubi8
    volumes:
      - mongodb_configdb:/data/configdb
      - mongodb_data:/data/db
    ports:
      - "27017:27017"
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${DB_ROOT_USER:-admin}
      MONGO_INITDB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-!ChangeMe!}

# Redis
# In-memory key-value database
# https://redis.io/fr/
  redis:
    image: redis:8.2
    command:
      - 'redis-server'
      - '--save 60 1'
      - '--loglevel verbose'
      - '--requirepass ${DB_ROOT_PASSWORD:-!ChangeMe!}'
    ports:
      - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "-a", "${DB_ROOT_PASSWORD:-!ChangeMe!}", "--raw", "incr", "ping" ]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 20s
    volumes:
      - redis_data:/data

# Neo4J
# Des graphes ultra-rapides, à l’échelle du pétaoctet
# https://neo4j.com/
  neo4j:
    image: neo4j:5.26.12-community
    ports:
      - 7473:7473
      - 7474:7474
      - 7687:7687
    volumes:
      - neo4j_data:/data
      - neo4j_logs:/logs
    environment:
      NEO4J_AUTH: neo4j/${DB_ROOT_PASSWORD:-!ChangeMe!}


volumes:
  database_data:
  superset_home:
  couchdb_data:
  mongodb_data:
  mongodb_configdb:
  redis_data:
  neo4j_data:
  neo4j_logs:
