version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: wedding-api
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
    ports:
      - "8080:80"
    networks:
      - wedding-network
    depends_on:
      - db
    environment:
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=wedding_rsvp
      - DB_USERNAME=wedding_user
      - DB_PASSWORD=wedding_pass

  db:
    image: mysql:8.0
    container_name: wedding-db
    restart: unless-stopped
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    environment:
      MYSQL_DATABASE: wedding_rsvp
      MYSQL_USER: wedding_user
      MYSQL_PASSWORD: wedding_pass
      MYSQL_ROOT_PASSWORD: root_pass
    volumes:
      - db-data:/var/lib/mysql
      - ./specs/schema.sql:/docker-entrypoint-initdb.d/schema.sql
    ports:
      - "3306:3306"
    networks:
      - wedding-network

volumes:
  db-data:

networks:
  wedding-network:
    driver: bridge
