
services:
  backend:
    build: ../backend
    container_name: backend
    command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
    ports:
      - "8000:8000"
    environment:
      DATABASE_URL: postgresql+asyncpg://admin:your_strong_password@postgres:5432/ticket_db
      REDIS_URL: redis://redis:6379/0
    volumes:
      - ../backend:/app
    env_file:
      - .env
    depends_on:
      - postgres
      - redis
      - rabbitmq
    networks:
      - ticket-network

  worker:
    build: ../backend
    container_name: worker
    command: python worker.py
    env_file:
      - .env
    depends_on:
      - rabbitmq
      - minio
      - postgres
    networks:
      - ticket-network

  frontend:
    build:
      context: ../frontend-client
      dockerfile: Dockerfile
    container_name: frontend
    ports:
      - "3000:3000"
    environment:
      - NEXT_PUBLIC_API_URL=http://192.168.149.101:8000/api
    volumes:
      - ../frontend-client:/app
      - /app/node_modules
    networks:
      - ticket-network

  traefik:
    image: traefik:v3.6
    container_name: traefik
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--providers.docker.httpClientTimeout=300s"
      - "--entrypoints.web.address=:80"
    ports:
      - "8081:80"
      - "8082:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - ticket-network

  postgres:
    image: postgres:15-alpine
    container_name: postgres
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: your_strong_password
      POSTGRES_DB: ticket_db
    ports:
      - "5432:5432"
    volumes:
      - ~/ticket-system/data/postgres:/var/lib/postgresql/data
    networks:
      - ticket-network

  redis:
    image: redis:7-alpine
    container_name: redis
    command: redis-server --save 60 1 --loglevel warning
    volumes:
      - ~/ticket-system/data/redis:/data
    networks:
      - ticket-network

  rabbitmq:
    image: rabbitmq:3-management-alpine
    container_name: rabbitmq
    restart: unless-stopped
    environment:
      RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
      RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
    ports:
      - "5672:5672"
      - "15672:15672"
    volumes:
      - ~/ticket-system/data/rabbitmq:/var/lib/rabbitmq
    networks:
      - ticket-network

  minio:
    image: quay.io/minio/minio
    container_name: minio
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadminpassword
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - ~/ticket-system/data/minio:/data
    networks:
      - ticket-network

  node-exporter:
    image: prom/node-exporter:latest
    container_name: node-exporter
    restart: unless-stopped
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.rootfs=/rootfs'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
    ports:
      - "9100:9100"
    networks:
      - ticket-network

  docker-stats-exporter:
    image: wywywywy/docker_stats_exporter:latest
    container_name: docker-stats-exporter
    restart: unless-stopped
    ports:
      - "9487:9487"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - ticket-network

networks:
  ticket-network:
    driver: bridge