Skip to content

Commit be5884f

Browse files
committed
fix(config): add option to override port
- also fix the apache host for when certs are not provided
1 parent ff2e370 commit be5884f

File tree

5 files changed

+76
-25
lines changed

5 files changed

+76
-25
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
JQUERY_WP_HTTP_PORT=
2+
JQUERY_WP_HTTPS_PORT=

README.md

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,47 @@ define('SECURE_AUTH_KEY', 'put your unique phrase here');
2424
// etc.
2525
```
2626

27-
4. Run `docker compose up --build` to start the containers.
27+
4. Copy .env.example to .env and edit the file to define database credentials
2828

29-
5. Import the database from a production WordPress instance.
29+
```sh
30+
cp .env.example .env
31+
```
32+
33+
5. Optionally, add local SSL certs to the `ssl` directory.
34+
35+
* If you don't have any, you can generate them using [mkcert](https://github.com/FiloSottile/mkcert).
36+
Run the following:
37+
38+
```sh
39+
mkcert -install
40+
```
41+
42+
* Then, in the `ssl` directory, run:
43+
```sh
44+
mkcert \
45+
local.jquery.com \
46+
local.api.jquery.com \
47+
local.blog.jquery.com \
48+
local.learn.jquery.com \
49+
local.releases.jquery.com \
50+
local.jqueryui.com \
51+
local.api.jqueryui.com \
52+
local.blog.jqueryui.com \
53+
local.jquerymobile.com \
54+
local.api.jquerymobile.com \
55+
local.blog.jquerymobile.com \
56+
local.jquery.org \
57+
local.brand.jquery.org \
58+
local.contribute.jquery.org \
59+
local.meetings.jquery.org
60+
```
61+
Wildcards don't work for multi-level subdomains. Add each site to the list of domains.
62+
63+
* Rename the created certs to `cert.pem` and `cert-key.pem`.
64+
65+
6. Run `docker compose up --build` to start the containers.
66+
67+
7. Import the database from a production WordPress instance.
3068
3169
```sh
3270
# You need SSH admin access to this production server
@@ -44,7 +82,7 @@ scp wp-05.ops.jquery.net:~/wordpress.sql .
4482
docker exec -i jquerydb mysql -u root -proot < wordpress.sql
4583
```
4684
47-
6. Visit http://local.api.jquery.com:9412.
85+
8. Visit http://local.api.jquery.com, or https://local.api.jquery.com if you created certs.
4886
4987
## Updating
5088
@@ -67,13 +105,21 @@ docker exec -it jquerydb mysql -u root -proot
67105
68106
### Ports
69107
70-
If you already use port 9412 on your host, you can create a `.env` file in this directory and set the following environment variable with a port number of your own choosing:
108+
jquery-wp-docker is set up to use ports `80` and `443` by default so no extra work is needed to support SSL. However, if either port is in use on your host, you can create a `.env` file in this directory and set the following environment variable with a port number of your own choosing:
71109
72110
```
73111
JQUERY_WP_HTTP_PORT=8080
74112
```
75113
76-
Note that the MySQL port (JQUERY_WP_MYSQL_PORT=9414) is only exposed for debugging purposes, e.g. to allow you to connect to it from a GUI or some other tool. The webserver container connects to the MySQL container directly and does not use this port.
114+
Then, visit the port directly when visiting sites, e.g. http://local.api.jquery.com:4000.
115+
116+
#### A note about port 443
117+
118+
443 is only spun up by Apache if certs are available in the /ssl folder. However, the `docker-compose.yml` does still expose port `443` to the docker images's 443, even if nothing is listening on that port. This shouldn't be an issue in most cases, but the port can be changed in the `.env.` file to avoid any conflicts.
119+
120+
```
121+
JQUERY_WP_HTTPS_PORT=0
122+
```
77123
78124
### DNS
79125

apache/000-default.conf

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ ServerName local.jquery.com
1212
</Directory>
1313
</VirtualHost>
1414

15-
<VirtualHost *:443>
16-
SSLEngine on
17-
SSLCertificateFile /etc/apache2/ssl/cert.pem
18-
SSLCertificateKeyFile /etc/apache2/ssl/cert-key.pem
15+
<IfFile "/etc/apache2/ssl/cert.pem">
16+
<IfFile "/etc/apache2/ssl/cert-key.pem">
17+
<VirtualHost *:443>
18+
SSLEngine on
19+
SSLCertificateFile /etc/apache2/ssl/cert.pem
20+
SSLCertificateKeyFile /etc/apache2/ssl/cert-key.pem
1921

20-
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.jquerymobile.com
21-
DocumentRoot /var/www/html
22-
php_value memory_limit 1024M
23-
<Directory /var/www/html>
24-
Options All
25-
AllowOverride All
26-
Order allow,deny
27-
Allow from all
28-
</Directory>
29-
</VirtualHost>
22+
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.jquerymobile.com
23+
DocumentRoot /var/www/html
24+
php_value memory_limit 1024M
25+
<Directory /var/www/html>
26+
Options All
27+
AllowOverride All
28+
Order allow,deny
29+
Allow from all
30+
</Directory>
31+
</VirtualHost>
32+
</IfFile>
33+
</IfFile>

docker-compose.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
- WORDPRESS_DB_HOST=jquerydb:3306
1212
- WORDPRESS_DB_USER=root
1313
- WORDPRESS_DB_PASSWORD=root
14+
- JQUERY_WP_HTTP_PORT=${JQUERY_WP_HTTP_PORT}
1415
volumes:
1516
- ./jquery-wp-content:/var/www/html/wp-content
1617
- ./uploads:/var/www/html/wp-content/uploads:rw
@@ -19,8 +20,8 @@ services:
1920
- ./apache/.htaccess:/var/www/html/.htaccess
2021
- ./apache/000-default.conf:/etc/apache2/sites-available/000-default.conf
2122
ports:
22-
- "80:80"
23-
- "443:443"
23+
- "${JQUERY_WP_HTTP_PORT:-80}:80"
24+
- "${JQUERY_WP_HTTPS_PORT:-443}:443"
2425
networks:
2526
- jquerynet
2627

@@ -32,8 +33,6 @@ services:
3233
- MYSQL_ROOT_PASSWORD=root
3334
volumes:
3435
- jquerydbdata:/var/lib/mysql
35-
ports:
36-
- "3306:3306"
3736
networks:
3837
- jquerynet
3938

wp-config-sample.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
/*
77
* jQuery.com settings
88
*/
9+
$port = getenv('JQUERY_WP_HTTP_PORT');
10+
define( 'JQUERY_STAGING_FORMAT', $port ? 'local.%s:' . $port : 'local.%s' );
911

1012
define( 'JQUERY_STAGING', true );
11-
// define( 'JQUERY_STAGING_FORMAT', 'local.%s:9412' );
12-
define( 'JQUERY_STAGING_FORMAT', 'local.%s' );
1313
require_once __DIR__ . '/wp-content/sites.php' ;
1414
define( 'JQUERY_LIVE_SITE', jquery_site_extract( $_SERVER['HTTP_HOST'] ?? 'jquery.com' ) );
1515

0 commit comments

Comments
 (0)