services:
  app:
    build:
      context: .
      dockerfile: docker/Dockerfile
    container_name: intellisight-api
    expose:
      - "4000"
    volumes:
      - uploads:/app/public/images
    depends_on:
      db:
        condition: service_healthy
    restart: unless-stopped

  db:
    build:
      context: ./docker
      dockerfile: Dockerfile.db
    container_name: intellisight-db
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASS}
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASS}
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  mysql_data:
  uploads:
