{"id":15014444,"url":"https://github.com/chriszarate/docker-compose-wordpress","last_synced_at":"2025-07-10T16:08:06.241Z","repository":{"id":47160348,"uuid":"83986287","full_name":"chriszarate/docker-compose-wordpress","owner":"chriszarate","description":"An example Docker Compose setup for WordPress plugin or theme development.","archived":false,"fork":false,"pushed_at":"2021-09-10T14:53:48.000Z","size":46,"stargazers_count":163,"open_issues_count":6,"forks_count":54,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-07T20:49:39.587Z","etag":null,"topics":["docker","docker-compose","phpunit","wordpress","wp-cli"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chriszarate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-05T16:50:27.000Z","updated_at":"2025-01-18T14:44:27.000Z","dependencies_parsed_at":"2022-09-04T02:41:48.856Z","dependency_job_id":null,"html_url":"https://github.com/chriszarate/docker-compose-wordpress","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chriszarate/docker-compose-wordpress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriszarate%2Fdocker-compose-wordpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriszarate%2Fdocker-compose-wordpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriszarate%2Fdocker-compose-wordpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriszarate%2Fdocker-compose-wordpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chriszarate","download_url":"https://codeload.github.com/chriszarate/docker-compose-wordpress/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriszarate%2Fdocker-compose-wordpress/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264604938,"owners_count":23635968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","phpunit","wordpress","wp-cli"],"created_at":"2024-09-24T19:45:38.554Z","updated_at":"2025-07-10T16:08:06.200Z","avatar_url":"https://github.com/chriszarate.png","language":"Shell","readme":"# WordPress plugin or theme development with Docker Compose\n\n[![Build status][build-status]][travis-ci]\n\nThis is an example repo for how one might wire up Docker Compose for local\nplugin or theme development. It provides WordPress, MariaDB, WP-CLI, PHPUnit,\nand the WordPress unit testing suite.\n\n\n## Set up\n\n1. Clone or fork this repo.\n\n2. Put your plugin or theme code in the root of this folder and adjust the \n   `services/wordpress/volumes` section of `docker-compose.yml` so that it\n   syncs to the appropriate directory.\n\n3. Add `project.test` to `/etc/hosts`, e.g.:\n\n   ```\n   127.0.0.1 localhost project.test\n   ```\n\n\n## Start environment\n\n```sh\ndocker-compose up -d\n```\n\nThe first time you run this, it will take a few minutes to pull in the required\nimages. On subsequent runs, it should take less than 30 seconds before you can\nconnect to WordPress in your browser. (Most of this time is waiting for MariaDB\nto be ready to accept connections.)\n\nThe `-d` flag backgrounds the process and log output. To view logs for a\nspecific container, use `docker-compose logs [container]`, e.g.:\n\n```sh\ndocker-compose logs wordpress\n```\n\nPlease refer to the [Docker Compose documentation][docker-compose] for more\ninformation about starting, stopping, and interacting with your environment.\n\n\n## Install WordPress\n\n```sh\ndocker-compose run --rm wp-cli install-wp\n```\n\nLog in to `http://project.test/wp-admin/` with `wordpress` / `wordpress`.\n\nAlternatively, you can navigate to `http://project.test/` and manually perform\nthe famous five-second install.\n\n\n## WP-CLI\n\nYou will probably want to [create a shell alias][3] for this:\n\n```sh\ndocker-compose run --rm wp-cli wp [command]\n```\n\nImport to and export from the WordPress database:\n\n```sh\ndocker-compose run --rm wp-cli wp db import - \u003c dump.sql\ndocker-compose run --rm wp-cli wp db export - \u003e dump.sql\n```\n\n## Running tests (PHPUnit)\n\nThe tests in this example repo were generated with WP-CLI, e.g.:\n\n```sh\ndocker-compose run --rm wp-cli wp scaffold plugin-tests my-plugin\n```\n\nThis is not required, however, and you can bring your own test scaffold. The\nimportant thing is that you provide a script to install your test dependencies,\nand that these dependencies are staged in `/tmp`.\n\nThe testing environment is provided by a separate Docker Compose file\n(`docker-compose.phpunit.yml`) to ensure isolation. To use it, you must first\nstart it, then manually run your test installation script. These commands work\nfor this example repo, but may not work for you if you use a different test\nscaffold.\n\nNote that, in the PHPUnit container, your code is mapped to `/app`.\n\n```sh\ndocker-compose -f docker-compose.yml -f docker-compose.phpunit.yml up -d\ndocker-compose -f docker-compose.phpunit.yml run --rm wordpress_phpunit /app/bin/install-wp-tests.sh wordpress_test root '' mysql_phpunit latest true\n```\n\nNow you are ready to run PHPUnit. Repeat this command as necessary:\n\n```sh\ndocker-compose -f docker-compose.phpunit.yml run --rm wordpress_phpunit phpunit\n```\n\n\n## Changing the hostname\n\nYou can change the hostname from the default `project.test` by adding a `.env`\nfile at the project root and defining the `DOCKER_DEV_DOMAIN` environment\nvariable:\n\n```\nDOCKER_DEV_DOMAIN=myproject.test\n```\n\n\n## Seed MariaDB database\n\nThe `mariadb` image supports initializing the database with content by mounting\na volume to the database container at `/docker-entrypoint-initdb.d`. See the\n[MariaDB Docker docs][mariadb-docs] for more information.\n\n\n## Troubleshooting\n\nIf your stack is not responding, the most likely cause is that a container has\nstopped or failed to start. Check to see if all of the containers are \"Up\":\n\n```\ndocker-compose ps\n```\n\nIf not, inspect the logs for that container, e.g.:\n\n```\ndocker-compose logs wordpress\n```\n\n## Extending\n\nExtend any of the predefined service images (wordpress, mysql, wp-cli, proxy) by adding your own [Dockerfile](https://docs.docker.com/engine/reference/builder) and replacing the docker-compose service `image` parameter to reference your Dockerfile. For example to add vim, soap and Xdebug, you make a file called `Dockerfile`:\n\n```\nFROM \"wordpress:${WP_VERSION:-5.2.1}-php${PHP_VERSION:-7.3}-apache\"\n# Or perhaps different default versions: \"wordpress:${WP_VERSION:-5.5.1}-php${PHP_VERSION:-7.4}-apache\"\n\nRUN apt-get update -y \\\n  \u0026\u0026 apt-get install -y \\\n      libxml2-dev \\\n      vim \\\n  \u0026\u0026 apt-get clean -y \\\n  \u0026\u0026 docker-php-ext-install soap  \\\n  \u0026\u0026 docker-php-ext-enable soap \\\n  \u0026\u0026 pecl install xdebug \\\n  \u0026\u0026 docker-php-ext-enable xdebug\n\nCOPY docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d\n\n```\nWhere you have added your `docker-php-ext-xdebug.ini` file alongside `docker-compose.yml`.\n\nThen you replace the `image` reference in the `docker-compose.yml` file's `wordpress` service section to just a `.` which will look for `Dockerfile` in the same directory. [Multiple Dockerfiles](https://stackoverflow.com/a/49811906/2223106) are possible as well.\n\nRun `docker-compose up -d --build {name-of-service-or-none-to-rebuild-all}` to rebuild that service. A usefile clean-up command to be aware of is [docker image prune](https://docs.docker.com/engine/reference/commandline/image_prune).\n\n\n[build-status]: https://travis-ci.org/chriszarate/docker-compose-wordpress.svg?branch=master\n[travis-ci]: https://travis-ci.org/chriszarate/docker-compose-wordpress\n[docker-compose]: https://docs.docker.com/compose/\n[mariadb-docs]: https://github.com/docker-library/docs/tree/master/mariadb#initializing-a-fresh-instance\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriszarate%2Fdocker-compose-wordpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchriszarate%2Fdocker-compose-wordpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriszarate%2Fdocker-compose-wordpress/lists"}