name: expomedics

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: expomedics_app
    restart: always
    ports:
      - "80:80"
    volumes:
      - .:/var/www/html
      - vendor:/var/www/html/vendor
    environment:
      RUN_MIGRATIONS: "false"
      DB_HOST: mysql
      DB_PORT: "3306"
      DB_DATABASE: expomedics
      DB_USERNAME: expomedics
      DB_PASSWORD: secret
    env_file:
      - .env
    depends_on:
      mysql:
        condition: service_healthy

  mysql:
    image: mysql:8.0
    container_name: expomedics_mysql
    restart: always
    ports:
      - "3307:3306"
    environment:
      MYSQL_DATABASE: expomedics
      MYSQL_USER: expomedics
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: rootsecret
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-prootsecret"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 30s

volumes:
  mysql_data:
  vendor:
