services: # Laravel Application app: build: context: . dockerfile: Dockerfile container_name: laravel_app restart: unless-stopped working_dir: /var/www volumes: - ./laravel:/var/www depends_on: db: condition: service_healthy environment: - DB_HOST=db - DB_PORT=3306 - DB_DATABASE=laravel - DB_USERNAME=laravel_user - DB_PASSWORD=secret_password command: sh -c "php artisan migrate --force && php-fpm" # MySQL Database db: image: mysql:8.0.32 container_name: mysql_db restart: unless-stopped ports: - "3306:3306" environment: - MYSQL_DATABASE=laravel - MYSQL_ROOT_PASSWORD=root_password - MYSQL_USER=laravel_user - MYSQL_PASSWORD=secret_password volumes: - dbdata:/var/lib/mysql healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot_password"] interval: 10s timeout: 10s retries: 10 # Nginx Web Server web: image: nginx:1.26.3-alpine container_name: nginx_web restart: unless-stopped ports: - "80:80" volumes: - ./laravel:/var/www - ./nginx/conf.d:/etc/nginx/conf.d depends_on: app: condition: service_started # We'll refine this later volumes: dbdata: