Ir al contenido
PHP Ecosystem
Explore

Validate a Docker environment

Esta página aún no está disponible en tu idioma.

Validate the image stack separately from the application. The portable helper checks Apache, PHP-FPM and filesystem behavior; it does not install Yii, connect to a database or replace application tests.

This Docker-only package has no Composer or PHP test suite. CI runs the shared repository quality checks, Hadolint, ShellCheck, workflow security, and Docker Buildx image builds.

Tool references:

CI runs actionlint, codespell, EditorConfig Checker, markdownlint-cli2, Prettier and yamllint through the shared yii2-framework/actions quality workflow. The repository’s formatting rules stay in .editorconfig.

Make actionlint and ShellCheck available on PATH to lint workflows locally.

Terminal window
actionlint

CI runs zizmor and Gitleaks through the shared security workflow. Gitleaks uses its default rules. The Gitleaks scan requires GITLEAKS_LICENSE in the workflow.

Make zizmor available on PATH to audit the workflows locally with the same pedantic persona.

Terminal window
zizmor --persona=pedantic .github

Zizmor needs GitHub API access for its online audits. Use the offline flag to run without API access.

Terminal window
zizmor --persona=pedantic --offline .github

The shared workflows’ pinned tool versions and hosted security credentials are separate from these local commands. Report hosted CI execution separately and keep generated reports in ignored internal/.

Hadolint and ShellCheck run through digest-pinned container images with the configuration in .github/linters. The helper requires Docker and matches the hadolint and shellcheck jobs of the quality workflow:

Terminal window
bash .github/scripts/lint.sh hadolint
bash .github/scripts/lint.sh shellcheck

The Docker image validation and build steps below also require Docker.

From a source checkout, pull a verified release and run the skill’s portable helper:

Terminal window
docker pull ghcr.io/yii2-extensions/apache:8.5-debian-dev-v2.0.0
bash skills/yii2-docker-environment/scripts/validate.sh \
ghcr.io/yii2-extensions/apache:8.5-debian-dev-v2.0.0

Requirements: Bash, Docker with a reachable local rootful Linux daemon without user-namespace remapping, curl, Python 3, and a non-root host user. The image must already exist locally. Rootless Docker and userns-remap change bind-mount UID/GID mapping; the helper rejects those modes before creating a fixture or container. These are helper restrictions, not an image compatibility claim; use application-specific mount ownership when running images with remapped UIDs. Do not change daemon configuration just to run the helper. The helper uses a temporary dependency-free fixture, the host UID:GID, an exclusive container ID, and dynamically allocated loopback HTTP/HTTPS ports. It checks application output, effective FPM memory settings, HTTPS, the internal health command, blocked external access to /__health, CLI execution, expected tools, and host file ownership. It removes its own container and fixture on success or failure, preserving images and all unrelated resources. It does not run Composer scripts or application migrations.

The helper uses a private :Z bind label for its disposable fixture so Docker can relabel it on SELinux hosts. Only the newly created fixture is relabeled; do not apply this option to system directories or shared application checkouts. See Docker’s SELinux bind-mount guidance.

Local image builds use the public image targets:

Terminal window
docker buildx bake image-8-5-dev --load
bash skills/yii2-docker-environment/scripts/validate.sh ghcr.io/yii2-extensions/apache:8.5-debian-dev

The CI build workflow builds images; maintainer regression tests are private and run separately. Image builds may download dependencies. Avoid the digest-* Bake targets for local validation: they push to the registry.

Install the application’s locked dependencies, including its development tools, before running its own test command. The image does not include PHPUnit, Codeception, a database server or a default test suite. From the quick-start container, when the application actually defines the tests Composer script:

Terminal window
docker exec -e COMPOSER_HOME=/tmp/app-composer app composer install --no-interaction --prefer-dist
docker exec app composer run tests

For an application with PHPUnit installed at vendor/bin/phpunit, use dev or full for Xdebug coverage:

Terminal window
docker exec -e XDEBUG_MODE=coverage app php vendor/bin/phpunit --coverage-text

XDEBUG_MODE=off avoids debugger overhead for ordinary test runs. Configure dedicated test database credentials and application state before tests that write data. YII_ENV=test enables entrypoint service waiting and skips startup migrations; it does not select or isolate a database for your test suite.

Record the image tag/digest, architecture, user, commands, assertions and any skipped checks. Read configuration when web and CLI PHP settings differ, and agent setup for skill installation and activation checks.

Back to documentation