services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        UID: 1000
        GID: 33
    image: controlplus-app
    env_file: .env
    depends_on:
      - db
    volumes:
      - .:/var/www/html:cached    # código + vendor + node_modules no host
    ports:
      - "5173:5173"
    networks:
      - controlplus

  web:
    image: nginx:1.25-alpine
    env_file: .env
    depends_on:
      - app
    ports:
      - "8000:80"
    volumes:
      - .:/var/www/html:cached
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    networks:
      - controlplus

  db:
    image: mysql:8.0
    env_file: .env
    restart: unless-stopped
    command: >
      --default-authentication-plugin=mysql_native_password
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_unicode_ci
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_USER: ${DB_USERNAME}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - controlplus

volumes:
  db_data:

networks:
  controlplus:
    driver: bridge
