From abe541c7ca2bb822bf07f16bc1e036cc5fb0a42a Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 17 Nov 2023 09:24:54 +0000 Subject: [PATCH] Automated documentation update [skip ci] --- src/wp-mysql/README.md | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/wp-mysql/README.md diff --git a/src/wp-mysql/README.md b/src/wp-mysql/README.md new file mode 100644 index 0000000..273be83 --- /dev/null +++ b/src/wp-mysql/README.md @@ -0,0 +1,70 @@ + +# WP & MySQL (wp-mysql) + +Develop WP applications with MySQL. + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| phpVersion | PHP version: | string | 7.4 | +| wpVersion | WP version: | string | 6.0 | +| contentPath | Content path: | string | themes | + +This template references an image that was [pre-built](https://containers.dev/implementors/reference/#prebuilding) to automatically include needed devcontainer.json metadata + +* **Image**: mcr.microsoft.com/devcontainers/php ([source](https://github.com/devcontainers/images/tree/main/src/php)) +* **Applies devcontainer.json contents from image**: Yes ([source](https://github.com/devcontainers/images/blob/main/src/php/.devcontainer/devcontainer.json)) + +## Using this template + +This template creates two containers, one for PHP and one for MySQL. You will be connected to the PHP container. The MySQL database has a default password of `wordpress` and you can update MySQL parameters by updating the `.devcontainer/docker-compose.yml` file. + +The template uses the `wpdevenv/php` image which includes `git`. This template add a non-root `vscode` user with `sudo` access. + +You can connect to MySQL from an external tool, it will be accessible from the Host machine at `localhost:9030` + +### Adding another service + +You can add other services to your `docker-compose.yml` file [as described in Docker's documentation](https://docs.docker.com/compose/compose-file/#service-configuration-reference). However, if you want anything running in this service to be available in the container on localhost, or want to forward the service locally, be sure to add this line to the service config: + +```yaml +# Runs the service on the same network as the database container, allows "forwardPorts" in devcontainer.json function. +network_mode: service:db +``` + +### Using the forwardPorts property + +By default, web frameworks and tools often only listen to localhost inside the container. As a result, we recommend using the `forwardPorts` property to make these ports available locally. + +```json +"forwardPorts": [9000] +``` + +The `ports` property in `docker-compose.yml` [publishes](https://docs.docker.com/config/containers/container-networking/#published-ports) rather than forwards the port. This will not work in a cloud environment like Codespaces and applications need to listen to `*` or `0.0.0.0` for the application to be accessible externally. Fortunately the `forwardPorts` property does not have this limitation. + +### Starting / stopping Apache + +This dev container includes Apache in addition to the PHP CLI. While you can use PHP's built in CLI (e.g. `php -S 0.0.0.0:8080`), you can start Apache by running: + +```bash +apache2ctl start +``` + +Apache will be available on port `8080`. + +If you want to wire in something directly from your source code into the `www` folder, you can add a symlink as follows to `postCreateCommand`: + +```json +"postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html" +``` + +...or execute this from a terminal window once the container is up: + +```bash +sudo chmod a+x "$(pwd)" && sudo rm -rf /var/www/html && sudo ln -s "$(pwd)" /var/www/html +``` + +--- + +_Note: This file was auto-generated from the [devcontainer-template.json](https://github.com/wpdevenv/dev_container_templates/blob/main/src/wp-mysql/devcontainer-template.json). Add additional notes to a `NOTES.md`._