devgiants / docker-wordpress
Ready-To-Start LAMP stack with Wordpress, WP-CLI and PHPMyAdmin
Package info
github.com/devgiants/docker-boilerplate-wordpress
Language:Just
Type:project
pkg:composer/devgiants/docker-wordpress
README
A ready-to-start Docker boilerplate for WordPress projects with:
- Apache 2.4 + PHP-FPM
- MariaDB
- WP-CLI
- phpMyAdmin
- Task automation with
just
Quick Start
Create a new project from this template:
composer create-project devgiants/docker-wordpress target-dir
Without a version constraint, Composer installs the latest stable release.
If you want HEAD of main, use:
composer create-project devgiants/docker-wordpress target-dir dev-main
Then go into your project directory and update .env.
Prerequisites
- Docker + Docker Compose plugin (
docker composecommand) just(task runner)composer(only needed if you bootstrap withcomposer create-project)envsubst
Install just
Use your preferred package manager:
# macOS (Homebrew) brew install just # Rust toolchain (cross-platform) cargo install just # Ubuntu/Debian (if available in your repos) sudo apt install just
If your distro package is unavailable/outdated, use cargo install just.
Install envsubst
On macOS:
brew install gettext brew link --force gettext
On most Linux distros, envsubst is provided by gettext.
Configuration (.env)
Set all values before first initialization.
Directories
WORDPRESS_HOST_RELATIVE_APP_PATH: host path mounted to/var/www/html(default./)LOGS_DIR: Apache logs directory on host
Runtime
PHP_VERSION: PHP version used to build the PHP containerMARIADB_VERSION: MariaDB image tagTIMEZONE: container timezone
Host Mapping
HOST_USER: your host usernameHOST_UID: your host UID (used for file ownership mapping)HOST_GID: your host GID
WordPress
PROJECT_NAME: WordPress site titleADMIN_USER: initial admin usernameADMIN_EMAIL: initial admin emailADMIN_PASSWORD: initial admin password (keep quotes if needed)BO_URL: back-office path slug used for authenticated warmup requests (for examplewp-admin); set it without leading/trailing slashWP_CLI_CACHE_DIR: WP-CLI cache pathDIVI_USERNAME: Elegant Themes username (used byjust set-divi-api-key)DIVI_API_KEY: Elegant Themes API key (used byjust set-divi-api-key)THEME_UPDATE_RECHECK_PASSES: number of HTTP warmup passes beforejust update-themes(default5)PLUGIN_UPDATE_RECHECK_PASSES: number of HTTP warmup passes beforejust update-plugins(default5)UPDATE_WARMUP_PASSES: fallback warmup pass count if specific vars above are not set (default5)UPDATE_WARMUP_SLEEP_SECONDS: delay between warmup passes (default2)
GitHub (used by just install-and-version)
GITHUB_NAME: GitHub owner/orgPROJECT_REPO: GitHub repository name
Database
MYSQL_HOST: DB host (mysqlby default, must match compose service name)MYSQL_DATABASE: DB nameMYSQL_DATABASE_PREFIX: WordPress table prefixMYSQL_USER: DB userMYSQL_PASSWORD: DB passwordMYSQL_HOST_PORT: host port mapped to DBMYSQL_PORT: DB port inside container (default3306)
Ports
APPLICATION_WEB_PORT: Apache exposed port (default80)PHP_MY_ADMIN_PORT: phpMyAdmin exposed port (default81)
Usage
List available recipes:
just --list
Initial project setup
just configure-wordpress
This recipe:
- builds/starts containers
- waits for DB readiness
- generates
wp-cli.ymlanddeploy.phpfrom.disttemplates - installs/configures WordPress
- installs a default plugin set
Day-to-day commands
just up # Start containers just down # Stop containers just build # Rebuild + start containers just bash-php # Shell in PHP container as www-data just bash-php-root # Shell in PHP container as root
Maintenance commands
just update-core just update-plugins just update-themes just warmup-updates just update-translations just update-all just search-replace just set-uploads-permissions just set-divi-api-key just erase-all
set-divi-api-key writes Divi update credentials to the WordPress option et_automatic_updates_options using WP-CLI.
warmup-updates emulates authenticated back-office page loads (/${BO_URL}/) + front-office hits + cron triggers to refresh update metadata (same effect as manual BO/FO navigation).
update-themes and update-plugins call this warmup automatically before applying updates (THEME_UPDATE_RECHECK_PASSES / PLUGIN_UPDATE_RECHECK_PASSES).
Core recipes can execute optional hooks when present:
update-themes-pre-hookupdate-themes-post-hookupdate-plugins-pre-hookupdate-plugins-post-hookerase-allis a destructive test helper: it stops/removes the compose stack, removes compose volumes, and deletes${GITHUB_NAME}/${PROJECT_REPO}on GitHub. It asks for an inlineYESconfirmation before running.
Private Just overlays
The root justfile can optionally import extra local files:
justfile.localjustfile.privatejustfile.user
Role of this feature:
- keep personal/team-specific recipes out of the shared
justfile - avoid committing private automation (local credentials, shortcuts, machine-specific tasks)
- extend project commands without changing versioned project files
- inject project-specific update logic (for example Divi/Elegant Themes fallbacks) via the optional hook recipes listed above
These files are ignored by git via justfile.*.
Example:
# justfile.private (not committed) deploy-prod: ./scripts/deploy-prod.sh
Repository bootstrap helper
just install-and-version
install-and-version assumes you are authenticated with GitHub CLI (gh auth login), bootstraps WordPress/GitHub/Git on first run, and skips GitHub bootstrap if the local git repo is already initialized.
Access URLs
- WordPress:
http://localhost:${APPLICATION_WEB_PORT}(defaulthttp://localhost) - phpMyAdmin:
http://localhost:${PHP_MY_ADMIN_PORT}(defaulthttp://localhost:81)
Reset From Scratch
- Stop containers:
docker compose down
- Remove WordPress files and DB data using the paths configured in
.env. - Re-run initialization:
just configure-wordpress
For full test reset (including remote GitHub repo deletion), use:
just erase-all
Notes
- WP-CLI commands should generally be run as
www-datainside the PHP container. configure-wordpressconsumes template files (wp-cli.yml.dist,deploy.php.dist) by generating runtime files and removing.distfiles.