version: "3.9"

networks
  hxki-internal:
    external: true

services

  # -------------------------------------------
  # POSTGRES (für n8n)
  # -------------------------------------------
  postgres:
    image: postgres:16
    container_name: hxki-postgres
    restart: unless-stopped
    networks:
      - hxki-internal
    environment:
      POSTGRES_USER: hxki
      POSTGRES_PASSWORD: supersecure
      POSTGRES_DB: hxki_roles
    volumes:
      - /opt/hx-ki/postgres:/var/lib/postgresql/data

      - "5432:5432"

  # -------------------------------------------
  # N8N – DAS MASTER-NERVENSYSTEM
  # -------------------------------------------
  n8n:
    image: docker.n8n.io/n8nio/n8n:latest
    container_name: hxki-n8n
    restart: unless-stopped
    depends_on:
      - postgres
    networks:
      - hxki-internal
    environment:
      N8N_HOST: n8n.hx-ki.com
      N8N_PORT: 5678
      WEBHOOK_URL: https://n8n.hx-ki.com/
      N8N_PROTOCOL: https
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_PORT: 5432
      DB_POSTGRESDB_USER: hxki
      DB_POSTGRESDB_PASSWORD: supersecure
      DB_POSTGRESDB_DATABASE: hxki_roles
      NATS_URL: nats://49.12.97.28:4222
    volumes:
      - /data/HXKI_WORKSPACE/router:/home/node/.n8n
      - /data/HXKI_WORKSPACE:/data/HXKI_WORKSPACE
    ports:
      - "5678:5678"

  # -------------------------------------------
  # CADDY – SUBDOMAINS, TLS, ROUTING
  # -------------------------------------------
  hxki-caddy:
    image: caddy:2
    container_name: hxki-caddy
    restart: unless-stopped
    networks:
      - hxki-internal
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /opt/hx-ki/docker/hxki-caddy/Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config

  # -------------------------------------------
  # GRAFANA
  # -------------------------------------------
  grafana:
    image: grafana/grafana-oss:latest
    container_name: hxki-grafana
    restart: unless-stopped
    networks:
      - hxki-internal
    ports:
      - "3000:3000"
    volumes:
      - /opt/hx-ki/grafana:/var/lib/grafana

  # -------------------------------------------
  # MARIA DB (für mautic)
  # -------------------------------------------
  mariadb:
    image: mariadb:10.11
    container_name: hxki-mariadb
    restart: unless-stopped
    networks:
      - hxki-internal
    environment:
      MYSQL_ROOT_PASSWORD: supersecure
      MYSQL_DATABASE: mautic
    volumes:
      - /opt/hx-ki/mariadb:/var/lib/mysql
    ports:
      - "3306:3306"

  # -------------------------------------------
  # MAUTIC
  # -------------------------------------------
  mautic:
    image: mautic/mautic:5-apache
    container_name: hxki-mautic
    restart: unless-stopped
    depends_on:
      - mariadb
    networks:
      - hxki-internal
    environment:
      MAUTIC_DB_HOST: mariadb
      MAUTIC_DB_USER: root
      MAUTIC_DB_PASSWORD: supersecure
      MAUTIC_DB_NAME: mautic
    ports:
      - "8080:80"

  # -------------------------------------------
  # GITEA
  # -------------------------------------------
  gitea:
    image: gitea/gitea:latest
    container_name: hxki-gitea
    restart: unless-stopped
    networks:
      - hxki-internal
    ports:
      - "3001:3000"
    volumes:
      - /var/lib/gitea:/data

volumes:
  caddy_data:
  caddy_config:
