Skip to content

Commit c82ea25

Browse files
committed
Change default localhost port to 9412
* Avoid use of the privileged port 80, because it tends to require extra rights, but also because it may be in use already in a way that's harder to turn off. Ports like 4000 are more often used via ad-hoc CLI procesess and presumably easier to turn off. For now pick an uncommon port number, to likely not even need to do that. * Remove the step to create `.env` by setting the root password explicitly in docker-compose.yml. * Remove support for SSL. Even with the new JQUERY_STAGING_FORMAT configuration, a site can still only have one canonical name in any given environment. One would need two separate installs of jquery-wp-docker or some other dynamic complexity, and set JQUERY_STAGING_FORMAT to :9412 for HTTP and e.g. :9413 for HTTPS to ensure that the canonical redirect goes to the correct destination, as well as to create links to other subdomains and pages with that same configuration. Instead of working on this more, I've removed it for now and instead made sure the HTTP version works as good as possible. I'm not aware of any HTTPS-specific features or behaviours on these sites that would benefit local HTTPS testing. If thre are any, we can work on a way to bring this back.
1 parent 973de7c commit c82ea25

File tree

8 files changed

+45
-81
lines changed

8 files changed

+45
-81
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
This file was deleted.

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ FROM php:8.2-apache
44
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
55
RUN apt-get update && apt-get upgrade -y
66

7-
RUN a2enmod ssl && a2enmod rewrite && \
8-
mkdir -p /etc/apache2/ssl && \
7+
RUN a2enmod rewrite && \
98
mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
109

1110
COPY ./WordPress /var/www/html

README.md

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

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

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.
29+
5. Import the database from a production WordPress instance.
6830

6931
```sh
7032
# You need SSH admin access to this production server
@@ -82,7 +44,7 @@ scp wp-05.ops.jquery.net:~/wordpress.sql .
8244
docker exec -i jquerydb mysql -u root -proot < wordpress.sql
8345
```
8446

85-
8. Visit http://local.api.jquery.com, or https://local.api.jquery.com if you created certs.
47+
6. Visit http://local.api.jquery.com:9412.
8648

8749
## Updating
8850

@@ -93,13 +55,39 @@ docker compose down
9355
docker compose up --build -d
9456
```
9557

96-
## Notes
58+
## Troubleshooting
59+
60+
### Ports
61+
62+
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:
63+
64+
```
65+
JQUERY_WP_HTTP_PORT=8080
66+
```
67+
68+
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.
69+
70+
### DNS
9771

98-
You do not need to configure your `/etc/hosts` file for `local.*` because `jquery.com`'s DNS handles this for you. However, if you plan to work offline, you can use the following rules:
72+
You do not need to configure your `/etc/hosts` file to define `local.jquery.com`, because we have defined these domains in the production DNS for jquery.com as alias for localhost. However, if you plan to work offline, you can add the following rules:
9973

10074
```
101-
127.0.0.1 local.jquery.com local.api.jquery.com local.blog.jquery.com local.releases.jquery.com local.learn.jquery.com local.plugins.jquery.com
102-
127.0.0.1 local.jqueryui.com local.api.jqueryui.com local.blog.jqueryui.com
103-
127.0.0.1 local.jquerymobile.com local.api.jquerymobile.com local.blog.jquerymobile.com
104-
127.0.0.1 local.jquery.org local.brand.jquery.org local.contribute.jquery.org local.events.jquery.org local.meetings.jquery.org
75+
127.0.0.1 local.jquery.com
76+
127.0.0.1 local.api.jquery.com
77+
127.0.0.1 local.blog.jquery.com
78+
127.0.0.1 local.learn.jquery.com
79+
127.0.0.1 local.releases.jquery.com
80+
81+
127.0.0.1 local.jqueryui.com
82+
127.0.0.1 local.api.jqueryui.com
83+
127.0.0.1 local.blog.jqueryui.com
84+
85+
127.0.0.1 local.jquerymobile.com
86+
127.0.0.1 local.api.jquerymobile.com
87+
127.0.0.1 local.blog.jquerymobile.com
88+
89+
127.0.0.1 local.jquery.org
90+
127.0.0.1 local.brand.jquery.org
91+
127.0.0.1 local.contribute.jquery.org
92+
127.0.0.1 local.meetings.jquery.org
10593
```

apache/000-default.conf

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,3 @@ ServerName local.jquery.com
1212
Allow from all
1313
</Directory>
1414
</VirtualHost>
15-
16-
# <VirtualHost *:443>
17-
# SSLEngine on
18-
# SSLCertificateFile /etc/apache2/ssl/cert.pem
19-
# SSLCertificateKeyFile /etc/apache2/ssl/cert-key.pem
20-
#
21-
# ServerName local.jquery.com
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>

docker-compose.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,31 @@ services:
77
context: .
88
dockerfile: Dockerfile
99
container_name: jquerysite
10-
env_file:
11-
- .env
1210
environment:
1311
- WORDPRESS_DB_HOST=jquerydb:3306
1412
- WORDPRESS_DB_USER=root
15-
- WORDPRESS_DB_PASSWORD=$MYSQL_ROOT_PASSWORD
13+
- WORDPRESS_DB_PASSWORD=root
1614
volumes:
1715
- ./jquery-wp-content:/var/www/html/wp-content
1816
- ./uploads:/var/www/html/wp-content/uploads:rw
1917
- ./wp-config.php:/var/www/html/wp-config.php
20-
- ./ssl:/etc/apache2/ssl
2118
- ./apache/.htaccess:/var/www/html/.htaccess
2219
- ./apache/000-default.conf:/etc/apache2/sites-available/000-default.conf
2320
ports:
24-
- "80:80"
25-
- "443:443"
21+
- "${JQUERY_WP_HTTP_PORT:-9412}:80"
2622
networks:
2723
- jquerynet
2824

2925
jquerydb:
3026
image: mariadb:10.11
3127
container_name: jquerydb
3228
restart: unless-stopped
33-
env_file:
34-
- .env
29+
environment:
30+
- MYSQL_ROOT_PASSWORD=root
3531
volumes:
3632
- jquerydbdata:/var/lib/mysql
3733
ports:
38-
- "3306:3306"
34+
- "${JQUERY_WP_MYSQL_PORT:-9414}:3306"
3935
networks:
4036
- jquerynet
4137

ssl/.gitkeep

Whitespace-only changes.

wp-config-sample.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
*/
99

1010
define( 'JQUERY_STAGING', true );
11-
define( 'JQUERY_STAGING_PREFIX', 'local.' );
12-
$live_site = preg_replace( '/:\d+$/', '', strtolower( $_SERVER['HTTP_HOST'] ?? 'jquery.com' ) );
13-
$live_site = strtr( $live_site, [ JQUERY_STAGING_PREFIX => '' ] );
14-
define( 'JQUERY_LIVE_SITE', $live_site );
11+
define( 'JQUERY_STAGING_FORMAT', 'local.%s:9412' );
12+
require_once __DIR__ . '/wp-content/sites.php' ;
13+
define( 'JQUERY_LIVE_SITE', jquery_site_extract( $_SERVER['HTTP_HOST'] ?? 'jquery.com' ) );
1514

1615
// WordPress debugging mode (enables PHP E_NOTICE and WordPress notices)
1716
define( 'WP_DEBUG', (bool) JQUERY_STAGING );

0 commit comments

Comments
 (0)