$ show docker-library/wordpress
This repository is the official Docker image build system for WordPress. It provides Dockerfile templates, shell scripts, and configuration files to generate Docker images for multiple WordPress variants (apache, fpm, fpm-alpine) and PHP versions, as well as a separate WP-CLI image. The core logic resides in the `docker-entrypoint.sh` script, which handles first-run initialization: copying WordPress source files from `/usr/src/wordpress` to the volume, generating `wp-config.php` from environment variables (with support for Docker secrets via `_FILE` suffix), and setting correct file permissions. The `wp-config-docker.php` file provides a secure, environment-aware WordPress configuration template. The build system uses a `Dockerfile.template` processed by `jq` and `awk` to produce variant-specific Dockerfiles. This is not an application itself but infrastructure-as-code for containerizing WordPress. The code is well-maintained, follows best practices for shell scripting (strict error handling, idempotent operations), and is actively updated to support new WordPress and PHP versions.
The LLM identified 3 files worth highlighting for reuse:
This is the primary entrypoint script for all WordPress Docker images (except CLI). It performs first-run initialization: checks if WordPress is installed, copies source from `/usr/src/wordpress` to the volume using `tar` to preserve permissions, skips existing pluggable content (e.g., plugins, themes) to avoid downgrades, and generates `wp-config.php` from environment variables with automatic salt generation. It handles running as non-root user, Docker secrets via `_FILE` environment variables, and Apache vs FPM configurations. The script is a robust example of a Docker entrypoint pattern that is idempotent and production-ready.
This is a modified version of the standard WordPress `wp-config.php` that reads database credentials, salts, and other settings from environment variables. It supports the common Docker secret pattern where a variable like `WORDPRESS_DB_PASSWORD_FILE` can be used instead of `WORDPRESS_DB_PASSWORD`. It includes a helper function `getenv_docker` that checks for `_FILE` first, then the primary variable, then falls back to a default. It also sets up HTTPS detection behind reverse proxies and allows additional configuration via `WORDPRESS_CONFIG_EXTRA`. This is a clean, reusable pattern for any Docker-based PHP application that needs config via environment.
This is a Jinja-like template (processed with `jq` and `awk` via `jq-template.awk`) that generates all variant-specific Dockerfiles. It uses conditional blocks to handle Alpine vs Debian, Apache vs FPM, and CLI vs web variants. It parameterizes PHP version, variant, WordPress version, and SHA checksums. The template is a good example of how to generate multiple Docker image variants from a single source efficiently, reducing duplication and ensuring consistency across images.