Skip to content

Commit 9a825d4

Browse files
authored
Merge pull request #292 from xwp/working-local-ssl
Add support for working SSL certificate using mkcert
2 parents a5bdc3c + ab65390 commit 9a825d4

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@
2424
.Trashes
2525
ehthumbs.db
2626
Thumbs.db
27+
28+
# Ignore Jetbrains IDE files
29+
.idea/

docker-compose.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- "80:80"
1212
- "443:443"
1313
volumes:
14-
- cert_data:/etc/nginx/certs
14+
- ./local/certs:/etc/nginx/certs
1515
- /var/run/docker.sock:/tmp/docker.sock:ro
1616
- ./local/docker/nginx-proxy/conf.d/custom.conf:/etc/nginx/conf.d/custom.conf
1717

@@ -31,9 +31,10 @@ services:
3131
image: ghcr.io/xwp/vip-site-template--mkcert:1.0.0
3232
build: ./local/docker/mkcert
3333
volumes:
34-
- cert_data:/root/.local/share/mkcert
34+
- ./local/certs:/root/.local/share/mkcert
3535
command: sh -c 'test -f "${DEV_URL:-local.wpenv.net}.crt" || mkcert -cert-file "${DEV_URL:-local.wpenv.net}.crt" -key-file "${DEV_URL:-local.wpenv.net}.key" "${DEV_URL:-local.wpenv.net}" "*.${DEV_URL:-local.wpenv.net}"'
3636

37+
3738
# Sync VIP MySQL container and it's configurations - https://github.com/Automattic/vip-cli/blob/549a45a37bc254a39dba9ed23ac88174a35aa1da/assets/dev-env.lando.template.yml.ejs#L74-L75
3839
db:
3940
image: mysql:8.0
@@ -112,6 +113,5 @@ services:
112113

113114
volumes:
114115
db_data:
115-
cert_data:
116116
webgrind_data:
117117
elasticsearch_data:

local/certs/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"node": "^18"
55
},
66
"scripts": {
7+
"install-cert": "CAROOT=./local/certs mkcert -install",
78
"preinstall": "composer install",
89
"prepare": "git config core.hooksPath ./local/git-hooks",
910
"lint": "npm-run-all lint-*",

readme.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Site setup, development environment and deploy tooling for [WordPress VIP](https
3232

3333
We suggest using [Homebrew](https://brew.sh) on macOS or [Chocolatey](https://chocolatey.org) for Windows to install the project dependencies.
3434

35-
brew install git [email protected] composer node@18 mkcert
35+
brew install git [email protected] composer node@18 mkcert nss
3636
brew install --cask docker
3737

3838

@@ -99,7 +99,7 @@ Consider using a dedicated GitHub [machine user](https://docs.github.com/en/get-
9999

100100
1. Clone this repository:
101101

102-
git clone [email protected]:wpcomvip/devgo-vip.git
102+
git clone [email protected]:xwp/vip-site-template.git devgo-vip
103103

104104
2. Move into the project directory:
105105

@@ -109,21 +109,25 @@ Consider using a dedicated GitHub [machine user](https://docs.github.com/en/get-
109109

110110
npm install
111111

112-
4. Start the development environment using Docker:
112+
4. Install ssl certificate to add the certificate authority of the development environment [`local/data/mkcert/rootCA.pem`](local/data/mkcert/rootCA.pem) to the trusted list on your computer. Alternatively, [configure it manually](https://support.apple.com/guide/keychain-access/add-certificates-to-a-keychain-kyca2431/mac).
113+
114+
npm run install-cert
115+
116+
5. Start the development environment using Docker:
113117

114118
npm run start
115119

116120
and `npm run stop` to stop the virtual environment at any time. Run `npm run start-debug` to start the environment in debug mode where all output from containers is displayed. Run `npm run stop-all` to stop all active Docker containers in case you're running into port conflicts.
117121

118-
5. Install the local WordPress multisite environment:
122+
6. Install the local WordPress multisite environment:
119123

120124
npm run setup
121125

122126
with the configuration from `local/public/wp-cli.yml`.
123127

124-
6. Visit [local.wpenv.net](https://local.wpenv.net) to view the development environment. WordPress username `devgo` and password `devgo`.
128+
7. Visit [local.wpenv.net](https://local.wpenv.net) to view the development environment. WordPress username `devgo` and password `devgo`.
125129

126-
7. Visit [mail.local.wpenv.net](https://mail.local.wpenv.net) to view all emails sent by WordPress.
130+
8. Visit [mail.local.wpenv.net](https://mail.local.wpenv.net) to view all emails sent by WordPress.
127131

128132
The local development environment uses a self-signed SSL sertificate for HTTPS so the "Your connection is not private" error can be ignored to visit the site.
129133

@@ -199,6 +203,8 @@ We use `npm` as the canonical task runner for things like linting files and crea
199203

200204
- `npm run vip` to run [VIP CLI](https://wpvip.com/documentation/vip-go/vip-cli/) commands on staging and production environments.
201205

206+
- `npm run install-cert` to mark the self-signed SSL certificate authority (under [`local/certs/rootCA.pem`](local/certs/rootCA.pem)) for the local development environment as trusted. Make sure [`mkcert` is installed on your computer](#install-dependencies). This command is required to avoid the "Your connection is not private" error when visiting the site. Stop the local environment before running this command and restart the browser/tab after installing the certificate and starting the environment again.
207+
202208

203209
## Deployments 🚀
204210

0 commit comments

Comments
 (0)