version: "3.9"

services:
  postgres:
    image: postgres:16
    container_name: veza-lab-postgres
    environment:
      POSTGRES_USER: veza
      POSTGRES_PASSWORD: veza_password
      POSTGRES_DB: veza_lab
    ports:
      - "5432:5432"
    volumes:
      - postgres_lab_data:/var/lib/postgresql/data
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U veza -d veza_lab" ]
      interval: 5s
      timeout: 3s
      retries: 10
    networks:
      - veza-lab-net

  redis:
    image: redis:7
    container_name: veza-lab-redis
    ports:
      - "6379:6379"
    healthcheck:
      test: [ "CMD", "redis-cli", "ping" ]
      interval: 5s
      timeout: 3s
      retries: 5
    networks:
      - veza-lab-net

  rabbitmq:
    image: rabbitmq:3-management
    container_name: veza-lab-rabbitmq
    ports:
      - "5672:5672"
      - "15672:15672"
    environment:
      RABBITMQ_DEFAULT_USER: veza
      RABBITMQ_DEFAULT_PASS: veza_password
    healthcheck:
      test: [ "CMD", "rabbitmq-diagnostics", "-q", "ping" ]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - veza-lab-net

  haproxy:
    image: haproxy:lts-alpine
    container_name: veza-lab-haproxy
    ports:
      - "80:80"
      # - "443:443" # SSL disabled for now
    volumes:
      - ../docker/haproxy/haproxy.lab.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
    extra_hosts:
      - "host.docker.internal:host-gateway"
    networks:
      - veza-lab-net

volumes:
  postgres_lab_data:


networks:
  veza-lab-net:
    driver: bridge
