version: '3.8'

services:
  db:
    image: postgres:13
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=testarena
    networks:
      - app-network
    restart: always

  backend:
    build: ./backend
    command: uvicorn app.main:app --host 0.0.0.0 --port 8000
    volumes:
      - ./backend:/app
      - ./results:/results
    ports:
      - "8000:8000"
    environment:
      - DATABASE_URL=postgresql://user:password@db/testarena
      - SCRIPTS_DIR=/app/scripts
    networks:
      - app-network
    restart: always

  frontend-builder:
    image: node:22-alpine
    working_dir: /app
    volumes:
      - ./frontend:/app
    command: sh -c "npm install && npm run build"
    profiles:
      - tools
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

volumes:
  postgres_data:
