version: '3.8' services: # PHP-FPM Application Server app: build: context: . dockerfile: docker/php/Dockerfile container_name: laravel_app restart: unless-stopped working_dir: /var/www/html volumes: - ./src:/var/www/html - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini networks: - laravel_network depends_on: - redis # Nginx Web Server nginx: image: nginx:alpine container_name: laravel_nginx restart: unless-stopped ports: - "${APP_PORT:-8080}:80" volumes: - ./src:/var/www/html - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf networks: - laravel_network depends_on: - app # ============================================ # DATABASE OPTIONS (use profiles to select) # Start with: docker-compose --profile mysql up # Or: docker-compose --profile pgsql up # Or: docker-compose --profile sqlite up # ============================================ # MySQL Database mysql: image: mysql:8.0 container_name: laravel_mysql restart: unless-stopped ports: - "${DB_PORT:-3306}:3306" environment: MYSQL_DATABASE: ${DB_DATABASE:-laravel} MYSQL_USER: ${DB_USERNAME:-laravel} MYSQL_PASSWORD: ${DB_PASSWORD:-secret} MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-rootsecret} volumes: - mysql_data:/var/lib/mysql - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf networks: - laravel_network profiles: - mysql # PostgreSQL Database pgsql: image: postgres:16-alpine container_name: laravel_pgsql restart: unless-stopped ports: - "${DB_PORT:-5432}:5432" environment: POSTGRES_DB: ${DB_DATABASE:-laravel} POSTGRES_USER: ${DB_USERNAME:-laravel} POSTGRES_PASSWORD: ${DB_PASSWORD:-secret} volumes: - pgsql_data:/var/lib/postgresql/data networks: - laravel_network profiles: - pgsql # SQLite (no container needed, just volume for persistence) # SQLite runs inside the app container # This is a dummy service to enable the sqlite profile sqlite: image: alpine:latest container_name: laravel_sqlite_init volumes: - ./src/database:/data command: sh -c "touch /data/database.sqlite && chmod 666 /data/database.sqlite" profiles: - sqlite # Redis Cache redis: image: redis:alpine container_name: laravel_redis restart: unless-stopped ports: - "${REDIS_PORT:-6379}:6379" volumes: - redis_data:/data networks: - laravel_network # Node.js for frontend assets (Vite/Mix) node: image: node:20-alpine container_name: laravel_node working_dir: /var/www/html volumes: - ./src:/var/www/html networks: - laravel_network command: sh -c "npm install && npm run dev" profiles: - frontend # Queue Worker (Laravel Horizon alternative for dev) queue: build: context: . dockerfile: docker/php/Dockerfile container_name: laravel_queue restart: unless-stopped working_dir: /var/www/html volumes: - ./src:/var/www/html - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini networks: - laravel_network depends_on: - redis command: php artisan queue:work redis --sleep=3 --tries=3 --max-time=3600 profiles: - queue # Scheduler (runs Laravel scheduler every minute) scheduler: build: context: . dockerfile: docker/php/Dockerfile container_name: laravel_scheduler restart: unless-stopped working_dir: /var/www/html volumes: - ./src:/var/www/html - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini networks: - laravel_network command: sh -c "while true; do php artisan schedule:run --verbose --no-interaction & sleep 60; done" profiles: - scheduler # Mailpit for local email testing mailpit: image: axllent/mailpit container_name: laravel_mailpit restart: unless-stopped ports: - "${MAIL_PORT:-1025}:1025" - "${MAIL_DASHBOARD_PORT:-8025}:8025" networks: - laravel_network networks: laravel_network: driver: bridge volumes: mysql_data: pgsql_data: redis_data: