Skip to content

Commit 2c2facc

Browse files
author
James Amner
authored
Merge pull request #302 from boxuk/BWP-117
[BWP-117] Migrated Documentation
2 parents 5af27b2 + 1c2db2f commit 2c2facc

24 files changed

+781
-101
lines changed

.github/workflows/docs.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish Docs
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
name: Publish to retype branch
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
name: Checkout
17+
- uses: actions/setup-dotnet@v1
18+
name: Setup
19+
with:
20+
dotnet-version: 7.0.x
21+
- uses: retypeapp/action-build@latest
22+
name: Build
23+
- uses: retypeapp/action-github-pages@latest
24+
name: Publish
25+
with:
26+
update-branch: true

docs/index.md

Lines changed: 0 additions & 6 deletions
This file was deleted.
59.4 KB
Loading

docs/skeleton/assets/logo.svg

Lines changed: 1 addition & 0 deletions
Loading
228 KB
Loading
164 KB
Loading
202 KB
Loading

docs/skeleton/docker-setup.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Docker Setup
2+
3+
If you just want a ready to go docker environment you can just use the [quickstart](quickstart.md), do read on though if you're after more detail.
4+
5+
### Pre-requisites
6+
#### Pre-requisites for Windows systems
7+
* [WSL](https://docs.microsoft.com/en-us/windows/wsl/install)
8+
* [Linux Kernel Update Package](https://docs.microsoft.com/en-gb/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package)
9+
* [Cygwin](https://cygwin.com/install.html) (be sure to include the gettext package on install)
10+
#### Pre-requisites for all systems
11+
* [Docker](https://www.docker.com/)
12+
* [Docker compose](https://docs.docker.com/compose/install/)
13+
14+
### Env Vars
15+
16+
You will also need to set up a bunch of environment variables
17+
18+
#### .env
19+
20+
Create a `.env` file based on `.env.dist`.
21+
22+
On Linux systems you will want to set `USER_ID` and
23+
`GROUP_ID` to the uid/gid of your primary user. These
24+
do not need to be set on Windows/Mac systems.
25+
26+
#### ./docker/database/.env
27+
28+
Create the `.env` file baed on `.env.dist`.
29+
30+
It is recommended to change the default passwords even
31+
for development environments.
32+
33+
#### ./docker/app/.env
34+
35+
Create the `.env` file based on `.env.dist`.
36+
37+
It is recommended to change the default passwords even
38+
for development environments.
39+
40+
> Env vars declared here will override any vars declared in the `.env` file in the root. See the header comment within the root `.env.dist` for an explanation as to why, baring in mind that in this context the 'real' environment is docker.
41+
42+
### Hosts file entries
43+
44+
`127.0.0.1 $PROJECT_NAME.local`
45+
46+
> If you want to change this you can, but you will need to make a change to `WP_HOME` in `./docker/app/.env`.
47+
48+
### Create environment
49+
50+
* `docker network create --subnet=192.168.35.0/24 $DOCKER_NETWORK_NAME`
51+
52+
> The docker network is required to ensure the loopback works with the expected IP address.
53+
54+
* `docker-compose build`
55+
56+
> This only needs to be called once to build the image(s)
57+
58+
* Use `docker-compose up` to build the containers. You'll only need to use this the first time.
59+
60+
* Use `docker-compose start` to start the container
61+
62+
* Use `docker-compose stop` to stop the container (without removing the volumes).
63+
64+
> Using docker-compose down stops containers but also removes them. This will lead to loss of data (e.g. your database).
65+
66+
That's it! You should now be able to browse to `https://$PROJECT_NAME.local` (or whatever you set) and view the site. Note, at time of writing you will need to go through the install script to have WordPress set up.
67+
68+
69+
### Running with Mac (And Docker Desktop)
70+
71+
#### Xdebug
72+
73+
We are running 2 app containers. By default, you will be using an xdebug-free container.
74+
This speeds up local env in browser and CLI as they no longer run xdebug for every request.
75+
76+
**Setup**
77+
78+
- Download a browser extension for your browser from https://www.jetbrains.com/help/phpstorm/2020.2/browser-debugging-extensions.html
79+
- Configure the browser extension to make sure the IDE key matches the one set in your `./docker/app/.env` (by default it is `wordpress`)
80+
81+
![Settings](./assets/browser-xdebug-helper-0.png)
82+
83+
- Ensure your IDE is set up correctly. Screenshots below show PhpStorm setup as an example.
84+
85+
![Settings](./assets/phpstorm-xdebug-0.png)
86+
87+
![Debugger](./assets/phpstorm-xdebug-1.png)
88+
89+
![Server](./assets/phpstorm-xdebug-2.png)
90+
91+
- To run xdebug in the browser: enable it in your IDE; add breakpoints; then go to your browser; enable xdebug in the browser extension (from first step of the setup) and reload the page.
92+
- To run xdebug in CLI: enable it in your IDE; add breakpoints; then execute the CLI command:
93+
94+
```
95+
docker-compose exec --user www-data app_xdebug php index.php
96+
```
97+
98+
Or, use one of the helper scripts located in `./bin/docker/xdebug`
99+
100+
> On linux, remember to set `remote_host` to `192.168.35.1`
101+
102+
### Running composer or wp-cli
103+
104+
If you wish to run composer or wp-cli there are two bin scripts that will allow you to run directly on the container:
105+
106+
`bin/docker/composer`
107+
`bin/docker/wp`

docs/skeleton/fixtures.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Fixtures
2+
3+
We are using [wp-cli-fixtures](https://github.com/nlemoine/wp-cli-fixtures) for fixtures.
4+
5+
## Install
6+
7+
`./bin/docker/wp package install [email protected]:nlemoine/wp-cli-fixtures.git`
8+
9+
## Usage
10+
11+
Fixtures can be added to `./fixtures.yml` see readme of [wp-cli-fixtures](https://github.com/nlemoine/wp-cli-fixtures) for more info.
12+
13+
## Load fixtures
14+
15+
Fixtures can be loaded with the following command:
16+
17+
`./bin/docker/wp fixtures load`
18+
19+
## Delete fixtures
20+
21+
If you wish to delete fixtures you've previously loaded, you can do so via:
22+
23+
`./bin/docker/wp fixtures delete`

docs/skeleton/https.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# HTTPS
2+
3+
As part of the nginx docker container we set up a self-signed certificate. This allows us to access the site locally using HTTPS. We do this, because all our websites are served over HTTPS and so we want to ensure we are doing the same locally.
4+
5+
The issue with self-signed certificates is browsers (quite rightly) deem them unsafe. You should too. **You should only bypass the security warnings of your browser if you are working on a secure network**.
6+
7+
## Using a local certificate authority (CA)
8+
9+
[The general recommended approach for not relying on self-signed certificates is to set up a local CA](https://web.dev/how-to-use-local-https/). There are several tools for doing this, but perhaps the easiest is [mkcert](https://github.com/FiloSottile/mkcert).
10+
11+
Before some basic instructions for setting this up, here is some information/disclaimer:
12+
13+
**Installing a local CA is at your own risk. Although it will only be trusted by you, a local CA will contaminate your trusted CAs. This means, if your local environment is compromised, or mkcert, then your entire HTTPS trust chain can easily be compromised too. It is for this reason we do not set this up by default and cannot recommend this approach.**
14+
15+
If you're comfortable with all that and still want to go ahead, here's how you can do it with mkcert.
16+
17+
### Install mkcert
18+
19+
On Mac:
20+
```bash
21+
brew install mkcert
22+
brew install nss # if you use Firefox
23+
```
24+
25+
For other platforms see: https://github.com/FiloSottile/mkcert#installation
26+
27+
### Add mkcert to your local root CAs
28+
29+
```bash
30+
mkcert -install
31+
```
32+
33+
### Generate a certificate
34+
35+
```bash
36+
mkcert my-project.local -cert-file docker/nginx/local_https_cert.pem -key-file docker/nginx/local_https_key.pem # Change the host accordingly
37+
```
38+
39+
### Update docker config
40+
41+
Add the following volumes to the `nginx` container within `docker-compose.yml`
42+
43+
```yaml
44+
- './docker/nginx/local_https_cert.pem:/etc/pki/tls/certs/local_https_cert.pem:delegated'
45+
- './docker/nginx/local_https_key.key:/etc/pki/tls/private/local_https_key.key:delegated'
46+
```
47+
48+
Update `docker/nginx/conf/app.conf` to point to your certificate and key:
49+
50+
```ini
51+
ssl_certificate /etc/pki/tls/certs/local_https_cert.pem;
52+
ssl_certificate_key /etc/pki/tls/local_https_key.pem;
53+
```
54+
55+
### Rebuild containers
56+
57+
`docker-compose stop; docker-compose build; docker-compose up`
58+
59+
## Any other options?
60+
61+
There are, this page from the chromium site lists a few other things you might want to try also: https://www.chromium.org/Home/chromium-security/deprecating-powerful-features-on-insecure-origins#TOC-Testing-Powerful-Features

0 commit comments

Comments
 (0)