{"id":20164889,"url":"https://github.com/somoscuatro/docker-wordpress-local","last_synced_at":"2025-03-03T03:15:03.164Z","repository":{"id":158954404,"uuid":"524384850","full_name":"somoscuatro/docker-wordpress-local","owner":"somoscuatro","description":"Local Docker Environment for WordPress Projects.","archived":false,"fork":false,"pushed_at":"2024-07-29T11:50:49.000Z","size":23,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-13T14:32:52.359Z","etag":null,"topics":["alpine","docker","docker-compose","docker-image","mailhog","nginx","php-fpm","wordpress","wp-cli"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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/somoscuatro.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-13T11:50:59.000Z","updated_at":"2024-06-07T17:32:28.000Z","dependencies_parsed_at":"2024-11-14T00:36:04.477Z","dependency_job_id":"024e50b2-b2f7-45c0-b38f-eed5bf648c25","html_url":"https://github.com/somoscuatro/docker-wordpress-local","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somoscuatro%2Fdocker-wordpress-local","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somoscuatro%2Fdocker-wordpress-local/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somoscuatro%2Fdocker-wordpress-local/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somoscuatro%2Fdocker-wordpress-local/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/somoscuatro","download_url":"https://codeload.github.com/somoscuatro/docker-wordpress-local/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241600490,"owners_count":19988715,"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":["alpine","docker","docker-compose","docker-image","mailhog","nginx","php-fpm","wordpress","wp-cli"],"created_at":"2024-11-14T00:36:00.965Z","updated_at":"2025-03-03T03:15:03.144Z","avatar_url":"https://github.com/somoscuatro.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker WordPress Local\n\nThis repository contains a local WordPress environment Docker setup based on:\n\n- [Linux Alpine](https://www.alpinelinux.org/)\n- [PHP FPM](https://www.php.net/manual/en/install.fpm.php)\n- [nginx](https://www.nginx.com/)\n- [WP CLI](https://wp-cli.org/)\n- [Mailhog](https://github.com/mailhog/MailHog)\n- [Xdebug](https://xdebug.org/)\n\nComposer, Node and PNPM are also included as part of the WordPress image.\n\n## Prerequisites\n\nTo use this local environment, you need:\n\n1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/)\n1. Install [mkcert](https://github.com/FiloSottile/mkcert#macos): `brew install\nmkcert`\n\n## Usage\n\nTo use this image in an existing WordPress project:\n\n1. Copy the following to your project root directory:\n   1. The `docker-compose.yml` file.\n   1. The `.docker` folder.\n   1. The `.env.sample` file. Rename it to `.env`.\n1. Edit the `.env` environment constants with your project details.\n1. Go to your project root directory and move into the `.docker` folder:\n   1. Create a certs folder and move into it: `mkdir certs \u0026\u0026 cd certs`\n   1. Run `mkcert -key-file cert-key.pem -cert-file cert.pem your-project.test localhost`\n1. Adjust your project `wp-config.php` file:\n\n   ```php\n     // Database settings.\n     define( 'DB_NAME', getenv( 'DB_NAME' ) );\n     define( 'DB_USER', getenv( 'DB_USER' ) );\n     define( 'DB_PASSWORD', getenv( 'DB_PASSWORD' ) );\n     define( 'DB_HOST', getenv( 'DB_HOST' ) );\n     define( 'DB_CHARSET', 'utf8' );\n     define( 'DB_COLLATE', '' );\n\n     // Site URL settings.\n     define( 'WP_SITEURL', getenv( 'WP_SITEURL' ) );\n     define( 'WP_HOME', getenv( 'WP_HOME' ) );\n   ```\n\n1. Ensure your `/etc/hosts` file contains `127.0.0.1 your-project.test` or use a\n   tool such as [Dnsmasq](https://thekelleys.org.uk/dnsmasq/doc.html)\n1. Run `docker-compose up` from the project root directory.\n\n## How to Use WP CLI\n\nTo use WP CLI, run `docker-compose run --rm cli` followed by the WP CLI command.\nFor example: `docker-compose run --rm cli plugin list`.\n\nTip: You can create a shell alias: `alias dwp='docker-compose run --rm cli'`.\n\n## How to Use Composer\n\nTo execute Composer commands within the Docker environment, use the following syntax:\n\n`docker-compose run --rm wp composer [command]`\n\nIf you need to run Composer commands in a specific directory, you can utilize\nthe `--working-dir` option to designate the target directory. This is\nparticularly useful when you want to manage dependencies located\nin a subdirectory of your container.\n\nFor example, to install Composer dependencies for the WordPress theme\n[sc-starter-theme](https://github.com/somoscuatro/sc-starter-theme), run:\n\n`docker-compose run --rm wp composer install\n--working-dir=wp-content/themes/sc-starter-theme`\n\n## How to Use PNPM\n\nTo execute PNPM commands within the Docker environment, use the following\nsyntax:\n\n`docker-composer run --rm wp pnpm [command]`\n\nIf you need to run PNPM commands in a specific directory, you can utilize the\n`--dir` option to designate the target directory. This is particularly useful\nwhen you want to manage dependencies located in a subdirectory of your\ncontainer.\n\nFor example, to build assets for the WordPress theme\n[sc-starter-theme](https://github.com/somoscuatro/sc-starter-theme), run:\n\n`docker-compose run --rm wp pnpm --dir=wp-content/themes/sc-starter-theme run\nbuild`\n\n## How to Switch PHP Version\n\nTo switch the PHP version, change the related PHP_VERSION variable in the `.env`\nfile. Available versions are `8.3`, `8.2`, `8.0` and `7.4`. See [Docker Hub\nwordpress image\npage](https://hub.docker.com/_/wordpress/tags?page=\u0026page_size=\u0026ordering=\u0026name=cli-php7)\nfor more info about available tags.\n\n## How to Enable HTTPS\n\nBy default, HTTPS is enabled. To make it work, you need to install `mkcert`\nlibrary (see Prerequisite section) and generate SSL certificates (see step 3 of\nthe Usage section).\n\n## How to Use Xdebug\n\nXdebug is enabled by default. To use it with Visual Studio Code, you have to\ninclude `?XDEBUG_SESSION=TRUE` in the URL you are browsing, and you have to use\nthis `launch.json` settings:\n\n```JSON\n{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      \"name\": \"Listen for Xdebug\",\n      \"type\": \"php\",\n      \"request\": \"launch\",\n      \"port\": 9003,\n      \"pathMappings\": {\n        \"/var/www/html\": \"${workspaceFolder}\"\n      }\n    }\n  ]\n}\n```\n\nYou can enable/disable the Xdebug profiler by adding `profile` to the\n`XDEBUG_MODE` variable in `.env`, i.e. `XDEBUG_MODE=debug,profile`.\n\nBy default, requests end up in the `./profiling` directory. The files begin with\n`cachegrind.out.` and are suffixed with the process ID.\n\n## How to Use Mailhog\n\nTo use Mailhog, you have to install and activate [our mailhog plugin for\nWordPres](https://github.com/somoscuatro/mailhog). Then you can simply visit\nhttp://your-project.test:8025.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomoscuatro%2Fdocker-wordpress-local","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomoscuatro%2Fdocker-wordpress-local","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomoscuatro%2Fdocker-wordpress-local/lists"}