name: strike_arena

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: strike_arena_app
    restart: unless-stopped
    env_file:
      - .env
    expose:
      - "3000"
    volumes:
      - uploads_data:/app/uploads
    depends_on:
      db:
        condition: service_healthy
    networks:
      - backend
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3000/ || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 30s

  nginx:
    image: nginx:1.27-alpine
    container_name: strike_arena_nginx
    restart: unless-stopped
    depends_on:
      app:
        condition: service_healthy
    ports:
      - "10.20.0.20:18073:80"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    networks:
      - backend
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://127.0.0.1/health || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 10s

  db:
    image: mysql:8.4
    container_name: strike_arena_db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
    expose:
      - "3306"
    volumes:
      - db_data:/var/lib/mysql
      - ./init/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
    networks:
      - backend
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-u", "root", "--password=${MYSQL_PASSWORD}"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s

volumes:
  db_data:
  uploads_data:

networks:
  backend:
    driver: bridge
