version: '3.8'
services:
  rabbitmq:
    image: rabbitmq:3.13-management-alpine
    container_name: rabbitmq
    restart: unless-stopped
    hostname: rabbitmq-aimpress
    networks:
    - database-internal
    - traefik-public
    env_file:
    - .env
    environment:
      RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER}
      RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
      RABBITMQ_DEFAULT_VHOST: /
    volumes:
    - rabbitmq-data:/var/lib/rabbitmq
    - ./rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
    ports:
    - 127.0.0.1:5672:5672
    labels:
    - traefik.enable=true
    - traefik.http.routers.rabbitmq.rule=Host(`rabbitmq.ai-impress.com`)
    - traefik.http.routers.rabbitmq.entrypoints=websecure
    - traefik.http.routers.rabbitmq.tls.certresolver=cloudflare
    - traefik.http.services.rabbitmq.loadbalancer.server.port=15672
    - traefik.http.routers.rabbitmq.middlewares=authentik@file
    healthcheck:
      test: rabbitmq-diagnostics -q ping
      interval: 30s
      timeout: 10s
      retries: 5
volumes:
  rabbitmq-data: null
networks:
  database-internal:
    external: true
  traefik-public:
    external: true
