diff --git a/README.md b/README.md index cedde41..aa8ba70 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,25 @@ docker run -e CONTAINER_MODE=worker -e WORKER_COMMAND="php /var/www/html/artisan docker run --rm : php artisan about ``` +### Running using docker compose + +> Important: You must copy the `docker-compose.yml` file to your project root directory. + +```bash +# Full stack with redis +docker compose --profile with_redis up -d + +# Without redis +docker compose up -d + +# Only the HTTP server (without proxy) +docker compose up -d app + +# Stop the containers +docker compose --profile with_redis down +docker compose down +``` + ## Configuration ### Recommended `Swoole` options in `octane.php` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..542b95b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,63 @@ +version: '3.7' + +services: + + app: + build: + context: . + dockerfile: Swoole.Alpine.Dockerfile + image: php-swole-laravel-app + restart: always + env_file: + - .env + environment: + RUNNING_MIGRATIONS: true + ports: + - "8000:8000" + depends_on: + - db + + horizon: + image: php-swole-laravel-app + restart: always + env_file: + - .env + environment: + CONTAINER_MODE: horizon + depends_on: + - app + + scheduler: + image: php-swole-laravel-app + restart: always + env_file: + - .env + environment: + CONTAINER_MODE: scheduler + depends_on: + - app + + redis: + image: redis:7-alpine + restart: always + volumes: + - redis_data:/data + profiles: + - with_redis + + db: + image: mysql:latest + restart: always + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: laravelapp + MYSQL_USER: user + MYSQL_PASSWORD: password + # ports: + # - "3306:3306" + volumes: + - ./data:/var/lib/mysql + + +volumes: + redis_data: \ No newline at end of file