version: "3.9"

services:
  hxki-web:
    build:
      context: /opt/hx-ki/web/hx-ki-website
    restart: unless-stopped
    networks:
      - hxki-internal
  syncthing:
    image: lscr.io/linuxserver/syncthing:latest
    container_name: hxki-syncthing
    restart: unless-stopped
    networks:
      - hxki-internal
    volumes:
      - /opt/hx-ki/syncthing/config:/config
      - /opt/hx-ki/syncthing/data:/data

  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
    ports:
      - "5432:5432"

  n8n:
    image: docker.n8n.io/n8nio/n8n
    container_name: hxki-n8n
    restart: unless-stopped
    depends_on:
      - postgres
    networks:
      - hxki-internal
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_PORT: 5432
      DB_POSTGRESDB_USER: hxki
      DB_POSTGRESDB_PASSWORD: supersecure
      DB_POSTGRESDB_DATABASE: hxki_roles
      N8N_HOST: 0.0.0.0
      N8N_PORT: 5678
      N8N_PROTOCOL: http
    ports:
      - "5678:5678"

  web:
    image: nginx:latest
    container_name: hxki-web
    restart: unless-stopped
    networks:
      - hxki-internal
    volumes:
      - /opt/hx-ki/web:/usr/share/nginx/html:ro
    ports:
      - "80:80"

  mariadb:
    image: mariadb:10.11
    container_name: hxki-mariadb
    restart: unless-stopped
    networks:
      - hxki-internal
    environment:
      MYSQL_ROOT_PASSWORD: supersecure
      MYSQL_DATABASE: mautic
      MYSQL_USER: mautic
      MYSQL_PASSWORD: mauticpass
    volumes:
      - /opt/hx-ki/mautic/db:/var/lib/mysql
    ports:
      - "3306:3306"

  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: mautic
      MAUTIC_DB_PASSWORD: mauticpass
      MAUTIC_DB_NAME: mautic
      MAUTIC_TRUSTED_PROXIES: 0.0.0.0/0
    volumes:
      - /opt/hx-ki/mautic/app:/var/www/html
    ports:
      - "8080:80"

  gitea:
    image: gitea/gitea:latest
    container_name: hxki-gitea
    restart: unless-stopped
    networks:
      - hxki-internal
    volumes:
      - /opt/hx-ki/archive:/data
    ports:
      - "3000:3000"
      - "222:22"

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

networks:
  hxki-internal:
    external: true
