-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add Caddy service configuration and Docker setup for improved container management and testing. #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ontainer management and testing.
## Walkthrough
This change introduces a new Caddy-based Docker environment for a Yii 2.0 PHP application. It adds a Docker Compose configuration, Dockerfile, Caddyfile, and supervisord settings for Caddy and PHP-FPM. A new GitHub Actions job is created to run tests in this environment, mirroring existing workflows for other web servers.
## Changes
| Files/Paths | Change Summary |
|------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| .github/workflows/docker.yml | Added a `test-caddy` CI job to build, run, and test the app using the new Caddy Docker Compose setup; renamed some step names in existing jobs. |
| docker-compose.caddy.yml | New Docker Compose file defining the `yii2-caddy` service, environment, ports, and named volumes. |
| docker/caddy/Dockerfile | New Dockerfile for a PHP 8.4 FPM + Caddy image with extensions, Node.js, supervisor, and custom entrypoint. |
| docker/caddy/Caddyfile | New Caddy web server configuration for HTTPS, PHP-FPM, security headers, URL rewriting, and static assets. |
| docker/supervisord/conf.d/caddy-php-fpm.conf | New supervisord config to manage both `php-fpm` and `caddy` processes in the container. |
| README.md | Updated documentation to include Caddy environment setup and HTTPS port usage for all servers. |
| docker-compose.frankenphp.yml | Updated port mappings and reordered `tty: true` line in `yii2-frankenphp` service. |
| docker-compose.nginx.yml | Updated port mappings in `yii2-nginx` service. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant GitHub Actions
participant Docker Compose
participant yii2-caddy Container
participant Caddy
participant PHP-FPM
participant Codeception
GitHub Actions->>Docker Compose: Start services (docker-compose.caddy.yml)
Docker Compose->>yii2-caddy Container: Build and run
yii2-caddy Container->>Caddy: Start via supervisord
yii2-caddy Container->>PHP-FPM: Start via supervisord
GitHub Actions->>yii2-caddy Container: Run Codeception build/tests
Codeception->>Caddy: Make HTTP requests
Caddy->>PHP-FPM: Forward PHP requests
PHP-FPM-->>Caddy: Return responses
Caddy-->>Codeception: Return HTTP responses Possibly related PRs
Suggested labels
Poem
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #119 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 36 36
===========================================
Files 23 23
Lines 621 621
===========================================
Hits 621 621 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/docker.yml (1)
66-70
: Fix step naming inconsistency.The step naming is inconsistent with other test jobs. You have separate "Codeception build" step but then combine build and tests in the final step. For consistency with other jobs, either:
- Keep separate steps like
test-apache
(lines 38-42), or- Rename the second step to just "Run codeception tests"
Current other jobs have:
- name: Codeceptcion build. - name: Run codeception tests.Consider aligning with this pattern:
- name: Codeception build. run: docker exec yii2-caddy vendor/bin/codecept build - name: Run codeception tests. run: docker exec yii2-caddy vendor/bin/codecept run
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.github/workflows/docker.yml
(1 hunks)docker-compose.caddy.yml
(1 hunks)docker/caddy/Caddyfile
(1 hunks)docker/caddy/Dockerfile
(1 hunks)docker/supervisord/conf.d/caddy-php-fpm.conf
(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: terabytesoftw
PR: yii2-extensions/app-basic#102
File: docker/apache/Dockerfile:0-0
Timestamp: 2025-07-10T13:59:10.805Z
Learning: In docker/apache/Dockerfile, the queue.conf copy command is intentionally commented out because yii2-queue is optional. Users should uncomment the line `COPY docker/apache/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf` only if they install yii2-queue.
docker/supervisord/conf.d/caddy-php-fpm.conf (1)
Learnt from: terabytesoftw
PR: yii2-extensions/app-basic#102
File: docker/apache/Dockerfile:0-0
Timestamp: 2025-07-10T13:59:10.805Z
Learning: In docker/apache/Dockerfile, the queue.conf copy command is intentionally commented out because yii2-queue is optional. Users should uncomment the line `COPY docker/apache/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf` only if they install yii2-queue.
docker-compose.caddy.yml (1)
Learnt from: terabytesoftw
PR: yii2-extensions/app-basic#102
File: docker/apache/Dockerfile:0-0
Timestamp: 2025-07-10T13:59:10.805Z
Learning: In docker/apache/Dockerfile, the queue.conf copy command is intentionally commented out because yii2-queue is optional. Users should uncomment the line `COPY docker/apache/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf` only if they install yii2-queue.
docker/caddy/Dockerfile (1)
Learnt from: terabytesoftw
PR: yii2-extensions/app-basic#102
File: docker/apache/Dockerfile:0-0
Timestamp: 2025-07-10T13:59:10.805Z
Learning: In docker/apache/Dockerfile, the queue.conf copy command is intentionally commented out because yii2-queue is optional. Users should uncomment the line `COPY docker/apache/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf` only if they install yii2-queue.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: codeception / PHP 8.4-windows-latest
- GitHub Check: codeception / PHP 8.1-windows-latest
- GitHub Check: codeception / PHP 8.3-windows-latest
- GitHub Check: test-frankenphp
- GitHub Check: test-caddy
- GitHub Check: test-frankenphp
- GitHub Check: test-caddy
🔇 Additional comments (10)
docker/supervisord/conf.d/caddy-php-fpm.conf (1)
1-22
: Well-structured supervisord configuration with correct startup priorities.The configuration properly manages both PHP-FPM and Caddy processes with appropriate priority ordering (PHP-FPM starts first with priority 5, Caddy follows with priority 10). The user settings are correctly configured - PHP-FPM runs as root for socket permissions, while Caddy runs as www-data for security.
docker-compose.caddy.yml (1)
1-35
: Well-configured Docker Compose service for Caddy setup.The configuration is comprehensive with proper:
- Build arguments for flexible user/group configuration
- Environment variable handling with sensible defaults
- Port mappings aligned with Caddyfile (8081 for HTTP, 8444 for HTTPS)
- Named volumes for persistent storage of Caddy config/data and Composer cache
- Appropriate restart policy and TTY settings
docker/caddy/Dockerfile (4)
12-26
: Comprehensive PHP extension installation for Yii2.The PHP extensions selection covers all typical Yii2 requirements including database (pdo_mysql, pdo_pgsql), image processing (gd, imagick), internationalization (intl), and development tools (xdebug). Using mlocati/php-extension-installer is an excellent choice for reliable extension installation.
65-71
: Proper PHP-FPM Unix socket configuration.The PHP-FPM configuration correctly switches from TCP to Unix socket communication, which is more efficient for same-machine communication with Caddy. The ownership and permissions setup ensures proper access between PHP-FPM and Caddy processes.
76-77
: Consistent with yii2-queue optional pattern.The commented queue.conf line follows the established pattern from other Dockerfiles where yii2-queue is optional. Users can uncomment this line when they install yii2-queue.
84-90
: Excellent script validation practices.The script validation includes line ending conversion, executable permissions, and syntax checking. This prevents common deployment issues and ensures scripts are properly formatted.
docker/caddy/Caddyfile (4)
20-27
: Excellent security headers configuration.The security headers provide comprehensive protection:
- X-Frame-Options prevents clickjacking
- X-XSS-Protection enables browser XSS filtering
- X-Content-Type-Options prevents MIME sniffing
- HSTS enforces HTTPS for one year
- Server header removal reduces information disclosure
35-43
: Optimal static file caching configuration.The static file handling correctly identifies common web assets and applies aggressive caching (1 year max-age) which is perfect for versioned assets in production environments.
45-55
: Comprehensive access restrictions for Yii2 security.The access restrictions properly protect sensitive directories (
.git
,vendor
,runtime
, environment files) and prevent PHP execution in the assets directory, which is a crucial Yii2 security practice.
8-9
: Verify mkcert certificate setupNo mkcert commands or SSL mounts were found in the codebase, yet the Caddyfile references certificates in
/app/docker/ssl
. Please confirm that you have one of the following in place:
- An entrypoint or init script that generates mkcert certificates into
/app/docker/ssl
at container startup- A host volume mount of pre-generated certificates into
/app/docker/ssl
Key locations to review:
docker/caddy/Caddyfile
(lines 8–9)- Any
docker-compose*.yml
files for volume mappings- Entrypoint/init scripts touching the
ssl
directory
…rt mappings in Docker Compose files.
Summary by CodeRabbit
New Features
Chores