-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add Docker configuration for Yii2
application with Nginx
and Apache
setups.
#102
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
…d `Apache` setups.
Warning Rate limit exceeded@terabytesoftw has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 5 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
WalkthroughThis update introduces a complete Docker-based development and deployment environment for a Yii2 PHP application, supporting both Apache and Nginx web servers. It adds Docker Compose files, Dockerfiles, web server configurations, PHP settings, Supervisor process management, and supporting scripts for both web stacks. Additionally, a minor CSS adjustment is made for dark theme compatibility. A GitHub Actions workflow is added to automate building, testing, and running the application within Docker containers. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant DockerCompose
participant Supervisor
participant WebServer (Apache/Nginx)
participant PHP-FPM
participant Yii2App
Developer->>DockerCompose: docker-compose up (apache or nginx)
DockerCompose->>Supervisor: Start supervisord in container
Supervisor->>WebServer: Launch Apache or Nginx (foreground)
alt Nginx stack
Supervisor->>PHP-FPM: Launch PHP-FPM (foreground)
end
Supervisor->>Yii2App: Launch queue workers (4 processes)
Developer->>WebServer: Access app via mapped port (8080/8081)
alt Nginx stack
WebServer->>PHP-FPM: Proxy PHP requests
end
WebServer->>Yii2App: Serve application content
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #102 +/- ##
===========================================
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: 8
🔭 Outside diff range comments (1)
docker/apache/supervisord/supervisord.conf (1)
10-11
:supervisorctl
will not work without aunix_http_server
endpoint
[supervisorctl]
alone is a no-op—supervisorctl
needs an RPC socket defined in[unix_http_server]
(and usually[rpcinterface:supervisor]
).[unix_http_server] file = /var/run/supervisor.sock chmod = 0700 [supervisorctl] serverurl = unix:///var/run/supervisor.sockAdd these blocks or drop the empty section to avoid confusion.
♻️ Duplicate comments (2)
docker/nginx/supervisord/log/.gitignore (1)
1-2
: Same comment as for the Apache log directory.Rule is correct and consistent.
docker/apache/supervisord/conf.d/queue.conf (1)
8-9
: Same logging caveat as the Nginx variant – see earlier comment ondocker/nginx/supervisord/conf.d/queue.conf
.
🧹 Nitpick comments (12)
docker/apache/supervisord/conf.d/apache2.conf (1)
1-4
: Consider simplifying the command and adding group-kill flags.
apache2ctl -D FOREGROUND
already sourcesenvvars
and is the canonical foreground launcher.
Also add the same signal-propagation options as for Nginx to avoid zombie workers.-command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" +command=/usr/sbin/apache2ctl -D FOREGROUND +stopasgroup=true +killasgroup=true +stopsignal=WINCH ; graceful stop for Apachedocker/nginx/supervisord/supervisord.conf (1)
2-3
: Discarding all supervisord logs hampers debugging
logfile = /dev/null
means every supervisor message disappears.
At minimum pipe to stdout/stderr so container logs keep basic lifecycle info.-logfile = /dev/null +logfile = /dev/stdout +logfile_maxbytes = 0If absolute silence is required, consider
loglevel=error
instead.docker/apache/vhost.conf (1)
27-28
: Send Apache logs to stdout/stderr for Docker friendlinessInside containers it is conventional to forward logs to the main process output instead of
/var/log
.-ErrorLog ${APACHE_LOG_DIR}/error.log -CustomLog ${APACHE_LOG_DIR}/access.log combined +ErrorLog /proc/self/fd/2 +CustomLog /proc/self/fd/1 combinedThis keeps
docker logs
usable and avoids managing log rotation.docker/nginx/nginx.conf (1)
35-36
: Pipe Nginx logs to Docker loggerSame rationale as Apache:
-access_log /var/log/nginx/access.log main; -error_log /var/log/nginx/error.log warn; +access_log /proc/self/fd/1 main; +error_log /proc/self/fd/2 warn;Avoids log files that grow unbounded inside the container.
docker-compose.yml (1)
10-11
: Host-specific Composer cache path may break on non-Unix hosts
~/.composer-docker/cache
assumes *nix home resolution and will not work on Windows without WSL. Consider switching to a named volume:volumes: - composer-cache:/root/.composer/cache ... volumes: composer-cache:Keeps cross-platform setups friction-free.
docker/nginx/Dockerfile (1)
10-12
: Package layer could be slimmer and reproducibleCombine
apt-get update
, install and cleanup in a single layer and add--no-install-recommends
already used, plusset -euo pipefail
for robustness:RUN set -eux; \ apt-get update; \ apt-get install --no-install-recommends -y supervisor; \ rm -rf /var/lib/apt/lists/*
Minor, but keeps the image smaller and fails fast on errors.
docker-compose.nginx.yml (3)
10-13
: Host-home Composer cache mount is fragile across OSes
~/.composer-docker/cache
relies on shell expansion that will not resolve on Windows or when Docker runs as a system service without a user shell.
Consider parameterising the path or using an absolute path under the project directory to ensure portability:- - ~/.composer-docker/cache:/root/.composer/cache:delegated + - ./docker/cache/composer:/root/.composer/cache:delegated
10-13
:delegated
mount option is Docker-Desktop-onlyThe
:delegated
consistency flag is ignored on Linux and will trigger a warning on Docker Engine < 17.04. Use a standard bind mount unless you explicitly target Docker Desktop:- - ./docker/cache/composer:/root/.composer/cache:delegated + - ./docker/cache/composer:/root/.composer/cache
7-8
: Tag the built image or drop theimage:
key to avoid ambiguityWhen
build:
is present, theimage:
tag is used only as the name of the resulting image. If you also push/pull this tag from a registry, the dual behaviour can be confusing.
Either rename it to something versioned (e.g.yii2-nginx:8.4-fpm
) or remove the key and let Compose generate a local tag.docker/nginx/default.conf (2)
11-15
: Minor typos and deprecated header
- Comment typo: “decurity” → “security”.
X-XSS-Protection
is obsolete in modern browsers and can be removed.- # decurity headers + # security headers - add_header X-XSS-Protection "1; mode=block" always;
65-69
: Non-English comment and hard-coded path“ajustado a tu estructura” is Spanish; keep comments English for consistency.
Also consider parameterising the path instead of hard-coding/vendor|/runtime/
.- # deny access to PHP files in specific directories (ajustado a tu estructura) + # deny access to PHP files under vendor/ or runtime/ for additional safetydocker/apache/apache.conf (1)
90-93
:Timeout 500
is unusually highA 500-second socket timeout can tie up worker threads and hurt concurrency. The common range is 60-120 s; anything longer is generally pushed to upstream services (e.g. FPM, queue).
-Timeout 500 +# Timeout tuned for long-running uploads; lower if not required +Timeout 120
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (19)
docker-compose.nginx.yml
(1 hunks)docker-compose.yml
(1 hunks)docker/apache/Dockerfile
(1 hunks)docker/apache/apache.conf
(1 hunks)docker/apache/supervisord/conf.d/apache2.conf
(1 hunks)docker/apache/supervisord/conf.d/queue.conf
(1 hunks)docker/apache/supervisord/log/.gitignore
(1 hunks)docker/apache/supervisord/supervisord.conf
(1 hunks)docker/apache/vhost.conf
(1 hunks)docker/nginx/Dockerfile
(1 hunks)docker/nginx/default.conf
(1 hunks)docker/nginx/nginx.conf
(1 hunks)docker/nginx/supervisord/conf.d/nginx.conf
(1 hunks)docker/nginx/supervisord/conf.d/php-fpm.conf
(1 hunks)docker/nginx/supervisord/conf.d/queue.conf
(1 hunks)docker/nginx/supervisord/log/.gitignore
(1 hunks)docker/nginx/supervisord/supervisord.conf
(1 hunks)docker/php/php.ini
(1 hunks)src/framework/resource/css/site.css
(0 hunks)
💤 Files with no reviewable changes (1)
- src/framework/resource/css/site.css
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: terabytesoftw
PR: yii2-extensions/app-basic#97
File: docs/installation.md:5-8
Timestamp: 2025-07-09T14:52:41.210Z
Learning: The Yii2 framework has multiple active branches including the 2.0.x branch (maintenance/LTS) and the 22.0 branch (development). When specifying version requirements, "2.0.53+ or 22.x" is accurate and should not be changed to only reference the 2.x branch.
Learnt from: terabytesoftw
PR: yii2-extensions/app-basic#97
File: docs/installation.md:5-8
Timestamp: 2025-07-09T14:52:41.210Z
Learning: The Yii2 framework has multiple active branches including the 2.0.x branch (maintenance/LTS) and the 22.0 branch (development). When specifying version requirements, "2.0.53+ or 22.x" is accurate and should not be changed to only reference the 2.x branch.
⏰ 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). (1)
- GitHub Check: codeception / PHP 8.1-windows-latest
🔇 Additional comments (4)
docker/apache/supervisord/log/.gitignore (1)
1-2
: Log directory ignore rule looks good.Keeping the directory in the repo while ignoring its (potentially huge) runtime contents is standard practice.
No further action needed.docker/php/php.ini (1)
14-15
:opcache.validate_timestamps = 0
disables hot-reload – deliberate?With timestamp validation turned off, PHP will not pick up file changes until the FPM/Apache process restarts.
Great for prod performance, painful for local development (the stated goal of these Docker files). If the images are intended for dev, consider enabling it or allowing override via an environment variable-driven.ini
.No code change suggested here – confirm intent.
docker-compose.yml (1)
3-7
:image
+build
may cause unexpected cache behaviourWith both keys present Compose will tag the built image as
yii2-apache:84
, but will reuse a locally-cached image of that tag even when the Dockerfile changes unless--build
is forced. If you always want a fresh build, drop theimage:
line; if you want to pull, dropbuild:
.docker/apache/apache.conf (1)
227-234
: Good hardening directives
ServerTokens ProductOnly
,ServerSignature Off
,TraceEnable Off
, and denying access to.git
show solid security hygiene.
[program:php-fpm] | ||
command=/usr/local/sbin/php-fpm --nodaemonize | ||
autostart=true | ||
autorestart=true | ||
priority=5 | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 |
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.
🛠️ Refactor suggestion
Ensure PHP-FPM receives supervisor signals and logs correctly.
- PHP-FPM spawns children; propagate signals so they’re not left running.
- Unless
error_log
is set to/proc/self/fd/2
insidephp-fpm.conf
, stderr redirection here won’t catch engine errors. Clarify or document that in the image.
priority=5
+killasgroup=true
+stopasgroup=true
+stopsignal=QUIT
If php-fpm.conf
is still using the default file log, add:
error_log = /proc/self/fd/2
inside that config.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
[program:php-fpm] | |
command=/usr/local/sbin/php-fpm --nodaemonize | |
autostart=true | |
autorestart=true | |
priority=5 | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes=0 | |
[program:php-fpm] | |
command=/usr/local/sbin/php-fpm --nodaemonize | |
autostart=true | |
autorestart=true | |
priority=5 | |
killasgroup=true | |
stopasgroup=true | |
stopsignal=QUIT | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes=0 |
🤖 Prompt for AI Agents
In docker/nginx/supervisord/conf.d/php-fpm.conf around lines 2 to 10, ensure
PHP-FPM properly receives supervisor signals by configuring it to propagate
signals to child processes. Also, verify that the PHP-FPM configuration file
sets error_log to /proc/self/fd/2 so that stderr redirection in supervisord
captures PHP engine errors; if not, add the line error_log = /proc/self/fd/2 to
php-fpm.conf and document this requirement in the image setup.
…supervisord configurations.
… improved step descriptions.
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: 2
♻️ Duplicate comments (1)
docker/nginx/nginx.conf (1)
26-30
: SSL configuration properly hardenedThe TLS configuration now includes strong cipher suites, modern elliptic curves, and DH parameters as recommended in the previous review. This addresses the security concerns about weak cipher negotiation.
🧹 Nitpick comments (1)
.github/workflows/docker.yml (1)
27-31
: Simplify Docker Compose installationGitHub Actions runners typically have docker-compose pre-installed. Consider removing the manual installation steps to simplify the workflow.
- - name: Install docker compose. - run: | - sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version + - name: Verify docker compose. + run: docker-compose --versionIf you need a specific version, use the
docker/setup-buildx-action
which can handle Docker Compose versions.Also applies to: 75-79
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/docker.yml
(1 hunks)docker/nginx/nginx.conf
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 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/nginx/nginx.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.
⏰ 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). (3)
- GitHub Check: codeception / PHP 8.1-windows-latest
- GitHub Check: Test Apache Image
- GitHub Check: Test Nginx Image
🔇 Additional comments (2)
docker/nginx/nginx.conf (1)
40-54
: Gzip configuration follows best practicesThe gzip settings are well-configured with appropriate MIME types and compression level. The inclusion of
gzip_vary
ensures proper cache behavior with proxies..github/workflows/docker.yml (1)
129-129
: Ignore image name mismatch warningThe Docker Compose files explicitly define the images as
yii2-apache:84
(indocker-compose.yml
) andyii2-nginx:84
(indocker-compose.nginx.yml
), matching the security-scan configuration. No changes are needed here.Likely an incorrect or invalid review comment.
…nd Nginx CI workflow.
…nx, including Node.js installation and Codeception tests.
…2 module initialization in ContactControllerTest.
… nginx and correct docker-compose command.
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: 2
🧹 Nitpick comments (1)
docker/apache/Dockerfile (1)
23-27
: Future-proof the Supervisor program copies
Onlyapache2.conf
is copied; any additional program files added later will require editing the Dockerfile again. A wildcard keeps the Dockerfile agnostic while still leavingqueue.conf
commented in the repo for optional enablement.-COPY docker/apache/supervisord/conf.d/apache2.conf /etc/supervisor/conf.d/apache2.conf +# copy all *.conf files that are checked into conf.d +COPY docker/apache/supervisord/conf.d/*.conf /etc/supervisor/conf.d/Optional – feel free to keep the current explicit copy if you want stricter control.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
composer.lock
is excluded by!**/*.lock
📒 Files selected for processing (6)
.github/workflows/docker.yml
(1 hunks)docker-compose.nginx.yml
(1 hunks)docker-compose.yml
(1 hunks)docker/apache/Dockerfile
(1 hunks)docker/nginx/Dockerfile
(1 hunks)tests/Unit/ContactControllerTest.php
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- docker-compose.yml
- docker/nginx/Dockerfile
- docker-compose.nginx.yml
- .github/workflows/docker.yml
🧰 Additional context used
🧠 Learnings (2)
📓 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/apache/Dockerfile (3)
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.
Learnt from: terabytesoftw
PR: yii2-extensions/app-basic#97
File: docs/installation.md:5-8
Timestamp: 2025-07-09T14:52:41.210Z
Learning: The Yii2 framework has multiple active branches including the 2.0.x branch (maintenance/LTS) and the 22.0 branch (development). When specifying version requirements, "2.0.53+ or 22.x" is accurate and should not be changed to only reference the 2.x branch.
Learnt from: terabytesoftw
PR: yii2-extensions/app-basic#97
File: docs/installation.md:5-8
Timestamp: 2025-07-09T14:52:41.210Z
Learning: The Yii2 framework has multiple active branches including the 2.0.x branch (maintenance/LTS) and the 22.0 branch (development). When specifying version requirements, "2.0.53+ or 22.x" is accurate and should not be changed to only reference the 2.x branch.
🪛 GitHub Actions: ecs
tests/Unit/ContactControllerTest.php
[warning] 16-16: PhpCsFixer: Docblock annotation '@phpstan-var Yii2|null $tester' should be '@phpstan-var Yii2|null'. Fixable by running with '--fix'.
⏰ 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). (1)
- GitHub Check: codeception / PHP 8.2-windows-latest
🔇 Additional comments (2)
tests/Unit/ContactControllerTest.php (1)
38-38
: LGTM! Improved test assertion.The change from runtime assertion to PHPUnit assertion provides better test framework integration and clearer failure reporting. The descriptive error message about Yii2 module initialization is particularly helpful for debugging in the Docker-based testing environment.
docker/apache/Dockerfile (1)
1-1
: Tag availability confirmed:8.4-apache
exists on Docker Hub
Theyiisoftware/yii2-php:8.4-apache
tag is published and valid—no change to the Dockerfile is needed.Likely an incorrect or invalid review comment.
… ContactControllerTest PHPDoc annotation.
Summary by CodeRabbit
New Features
Style