version: "3.8"

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ./app:/var/www/html
    depends_on:
      - db
    networks:
      - app-network

  nginx:
    image: nginx:stable-alpine
    ports:
      - "80:80"
    volumes:
      - ./app:/var/www/html
      - ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app
    networks:
      - app-network

  db:
    image: mysql:8.0
    environment:
      MYSQL_DATABASE: reservas
      MYSQL_USER: reservas
      MYSQL_PASSWORD: reservas123
      MYSQL_ROOT_PASSWORD: root_password_here
    volumes:
      - ./db-data:/var/lib/mysql
    ports:
      - "3306:3306"   # optional, expose for local connections
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - app-network

volumes:
  db-data:

networks:
  app-network:
    driver: bridge