#version: "3.9"

services:
  backend:
    build: ./backend
    container_name: linux_benchtools_backend
    user: "1000:1000"
    ports:
      - "${BACKEND_PORT:-8007}:8007"
    volumes:
      - ./backend/data:/app/data
      - ./uploads:/app/uploads
      - ./backend/app:/app/app
      - ./config:/app/config:ro
    environment:
      - API_TOKEN=${API_TOKEN:-CHANGE_ME_GENERATE_RANDOM_TOKEN}
      - DATABASE_URL=sqlite:////app/data/data.db
      - UPLOAD_DIR=/app/uploads
      # Peripherals module
      - PERIPHERALS_MODULE_ENABLED=${PERIPHERALS_MODULE_ENABLED:-true}
      - PERIPHERALS_DB_URL=sqlite:////app/data/peripherals.db
      - PERIPHERALS_UPLOAD_DIR=/app/uploads/peripherals
      - IMAGE_COMPRESSION_ENABLED=true
      - IMAGE_COMPRESSION_QUALITY=85
    restart: unless-stopped
    networks:
      - benchtools

  frontend:
    image: nginx:alpine
    container_name: linux_benchtools_frontend
    ports:
      - "${FRONTEND_PORT:-8087}:80"
    volumes:
      - ./frontend:/usr/share/nginx/html:ro
      - ./frontend/nginx-main.conf:/etc/nginx/nginx.conf:ro
      - ./frontend/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - ./scripts/bench.sh:/usr/share/nginx/html/scripts/bench.sh:ro
      - ./uploads:/uploads:ro
    restart: unless-stopped
    networks:
      - benchtools

  iperf3:
    image: networkstatic/iperf3
    container_name: linux_benchtools_iperf3
    user: "1000:1000"
    command: ["-s"]
    ports:
      - "5201:5201/tcp"
      - "5201:5201/udp"
    restart: unless-stopped
    networks:
      - benchtools

networks:
  benchtools:
    driver: bridge
