version: '3.8'

services:
  app:
    container_name: container_latest
    image: fastapi
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "${PORT}:${PORT}"
    command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "${PORT}", "--reload"]
    restart: "no"
    environment:
      - MYSQL_HOST=db
      - MYSQL_PORT=3306
      - MYSQL_USER=${SQL_USER}
      - MYSQL_PASSWORD=${SQL_PASS}
      - MYSQL_DB=${SQL_DB}
    depends_on:
      - db

  db:
    image: mysql:8.0
    container_name: mysql
    environment:
      MYSQL_USER: myroot
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: cnc_database
      MYSQL_PASSWORD: password
    ports:
      - "3307:3306"
    volumes:
      - db_data:/var/lib/mysql

volumes:
  db_data:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: 'A:/mysql'
