version: '3.8'

services:
  db:
    image: postgres:15-alpine
    container_name: testarena_db
    environment:
      POSTGRES_DB: testarena
      POSTGRES_USER: testarena_user
      POSTGRES_PASSWORD: testarena_pass_change_me
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - app-network
    restart: unless-stopped

  web:
    build: .
    container_name: testarena_web
    environment:
      DATABASE_URL: postgresql://testarena_user:testarena_pass_change_me@db:5432/testarena
      SECRET_KEY: change_this_secret_key_in_production
      FLASK_ENV: production
    volumes:
      - ./app:/app/app
      - ./wsgi.py:/app/wsgi.py
      - test_results:/app/test_results
    depends_on:
      - db
    networks:
      - app-network
      - caddy_network
    restart: unless-stopped

volumes:
  postgres_data:
  test_results:

networks:
  app-network:
    driver: bridge
  caddy_network:
    external: true
