From 8ff556df88b288c60a8b40e96a51b1e8a0cedd80 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 12 May 2023 13:57:06 +0200 Subject: [PATCH] Dockerize using caddy and php-fpm --- Caddyfile | 8 ++++++++ README.md | 5 ++++- docker-compose.yml | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Caddyfile create mode 100644 docker-compose.yml diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..43f47fa --- /dev/null +++ b/Caddyfile @@ -0,0 +1,8 @@ +:80 { + root * /srv + encode gzip zstd + php_fastcgi php-fpm:9000 + file_server + # Force route through index.php + try_files {path} /index.php{path} +} diff --git a/README.md b/README.md index 05de191..2ea37fd 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,11 @@ This router is dependency-free. The only composer packages installed are [PHPStan](https://phpstan.org) and [PHPUnit](https://phpunit.de), for static code analysis and unit testing. Remove with -```zsh +```bash +# Remove composer things rm -rf vendor/ composer* .phpstan.neon .vscode/tasks.json +# Remove docker things +rm docker-compose.yml Caddyfile ``` and remove the autoloader from the `index.php` file. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1544792 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3' + +services: + caddy: + image: caddy:2-alpine + restart: unless-stopped + ports: + - 80:80 + - 443:443 + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile + - ./src:/srv + + php-fpm: + image: php:8.2-fpm-alpine + volumes: + - ./src:/srv