Skip to content

Commit 5c46bca

Browse files
committed
Migrate from legacy WPMU to new standalone WordPress model
* Remove use of jquery-wp-content/config.php and the WPMU sunrise and other customisations. Instead, mount jquery-wp-content as the literal /wp-content directory, and leave most settings at their default, matching the new production servers. * Update sync instructions to work for wp-05, noting that we now have multiple databases. So instead of one database with tables like wordpress.wp_1_posts and wordpress.wp_2_posts, we now have wordpress_jquery_com.wp_posts and wordpress_jqueryui_com.wp_posts. This means for local dev we need multiple databases as well, which the default docker config doesn't offer conveniently (it only has affordances to easily create 1 user and 1 database). Switch the instructions to use root instead during local development so that the `docker exec` command that imports the production databases will be able to automatically create all 14 databases, and likewise for Apache to be able to read-write data from each of them as well. Also: * Fix warning about unset ServerName. * Minor tweaks to config so that HTTPS is actually optional. Previous there'd be various errors during the build if Step 5 in the readme was skipped. * Remove sizzlejs.com from domain listings. * Update WordPress from 6.2.0 tag to 6.3.1 tag. * Make use of PHP 8.2.x explicit, matching Debian 12 and production. * Migrate from MySQL to MariaDB, matching prod. * Make use of MariaDB 10.11 explicit, matching prod. Ref jquery/infrastructure-puppet#6
1 parent c77cd01 commit 5c46bca

File tree

8 files changed

+71
-103
lines changed

8 files changed

+71
-103
lines changed

.env.example

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
MYSQL_DATABASE=
2-
MYSQL_ROOT_PASSWORD=
3-
MYSQL_USER=
4-
MYSQL_PASSWORD=
1+
MYSQL_ROOT_PASSWORD=root

Dockerfile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8-apache
1+
FROM php:8.2-apache
22

33
# Install MySQLi
44
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
@@ -8,19 +8,7 @@ RUN a2enmod ssl && a2enmod rewrite && \
88
mkdir -p /etc/apache2/ssl && \
99
mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
1010

11-
ENV NODE_VERSION=18.16.1
12-
RUN apt install -y curl
13-
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
14-
ENV NVM_DIR=/root/.nvm
15-
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
16-
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
17-
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
18-
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
19-
RUN node --version
20-
RUN npm --version
21-
2211
COPY ./WordPress /var/www/html
23-
# COPY ./jquery-wp-content /var/www/html/jquery-wp-content
2412

2513
EXPOSE 80
2614
EXPOSE 443

README.md

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,56 @@ define('SECURE_AUTH_KEY', 'put your unique phrase here');
3030
cp .env.example .env
3131
```
3232

33-
```sh
34-
MYSQL_DATABASE=your_database_name
35-
MYSQL_ROOT_PASSWORD=your_root_password
36-
MYSQL_USER=your_database_user_name
37-
MYSQL_PASSWORD=your_database_password
38-
```
39-
40-
5. Optionally, add local SSL certs to the `ssl` directory. If you don't have any, you can generate them using [mkcert](https://github.com/FiloSottile/mkcert). Run the following:
41-
42-
```sh
43-
mkcert -install
44-
```
45-
46-
Then, in the `ssl` directory, run:
47-
48-
```sh
49-
mkcert local.jquery.com local.blog.jquery.com local.api.jquery.com local.plugins.jquery.com local.learn.jquery.com local.jqueryui.com local.blog.jqueryui.com local.api.jqueryui.com local.jquerymobile.com local.api.jquerymobile.com local.jquery.org local.events.jquery.org local.brand.jquery.org local.contribute.jquery.org local.meetings.jquery.org local.releases.jquery.com
50-
```
51-
52-
Wildcards don't work for multi-level subdomains. Add each site to the list of domains.
53-
54-
**Rename the created certs to `cert.pem` and `cert-key.pem`.**
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`.
5564
5665
6. Run `docker compose up --build` to start the containers.
5766
58-
7. Fill the database with the latest data from production wordpress.
67+
7. Import the database from a production WordPress instance.
5968
6069
```sh
61-
ssh wp-01.ops.jquery.net # Your SSH key must be on the server
62-
mysqldump -u jq_wordpress -p wordpress > wordpress.sql # Credentials are in the vault
70+
# You need SSH admin access to this production server
71+
ssh wp-05.ops.jquery.net
72+
sudo -u tarsnap mysqldump --databases `sudo -u tarsnap mysql -B -N -e "SHOW DATABASES LIKE 'wordpress_%'"` > wordpress.sql
6373
```
6474
6575
Then, on your local machine, run:
6676
6777
```sh
68-
# This assumes your SQL dump is in your home directory on the server
69-
scp wp-01.ops.jquery.net:~/wordpress.sql .
70-
# These are the same as what's in your .env file
71-
# Note there is no space between -p and the password
72-
docker exec -i jquerydb mysql -u YOUR_MYSQL_USER -pYOUR_MYSQL_PASSWORD YOUR_MYSQL_DATABASE < wordpress.sql
78+
# Copy the SQL dump from your home directory on the server (as created by the previous command)
79+
scp wp-05.ops.jquery.net:~/wordpress.sql .
80+
# Docker root database password must match your .env file
81+
# NOTE: There must be no space between -p and the password!
82+
docker exec -i jquerydb mysql -u root -proot < wordpress.sql
7383
```
7484
7585
8. Visit http://local.jquery.com, or https://local.jquery.com if you created certs.

WordPress

Submodule WordPress updated 1113 files

apache/000-default.conf

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
1-
# <VirtualHost *:80>
2-
# ServerAdmin admin@localhost
3-
# ServerName localhost
4-
# DocumentRoot /var/www/html
5-
# ErrorLog ${APACHE_LOG_DIR}/error.log
6-
# CustomLog ${APACHE_LOG_DIR}/access.log combined
7-
# </VirtualHost>
8-
9-
# <VirtualHost *:443>
10-
# SSLEngine on
11-
# SSLCertificateFile /etc/apache2/ssl/cert.pem
12-
# SSLCertificateKeyFile /etc/apache2/ssl/cert-key.pem
13-
14-
# ServerAdmin admin@localhost
15-
# ServerName localhost
16-
# DocumentRoot /var/www/html
17-
# ErrorLog ${APACHE_LOG_DIR}/error.log
18-
# CustomLog ${APACHE_LOG_DIR}/access.log combined
19-
# </VirtualHost>
1+
ServerName local.jquery.com
202

213
<VirtualHost *:80>
224
ServerName local.jquery.com
23-
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.sizzlejs.com *.jquerymobile.com
5+
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.jquerymobile.com
246
DocumentRoot /var/www/html
257
php_value memory_limit 1024M
268
<Directory /var/www/html>
@@ -31,19 +13,19 @@
3113
</Directory>
3214
</VirtualHost>
3315

34-
<VirtualHost *:443>
35-
SSLEngine on
36-
SSLCertificateFile /etc/apache2/ssl/cert.pem
37-
SSLCertificateKeyFile /etc/apache2/ssl/cert-key.pem
38-
39-
ServerName local.jquery.com
40-
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.sizzlejs.com *.jquerymobile.com
41-
DocumentRoot /var/www/html
42-
php_value memory_limit 1024M
43-
<Directory /var/www/html>
44-
Options All
45-
AllowOverride All
46-
Order allow,deny
47-
Allow from all
48-
</Directory>
49-
</VirtualHost>
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: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ services:
1111
- .env
1212
environment:
1313
- WORDPRESS_DB_HOST=jquerydb:3306
14-
- WORDPRESS_DB_USER=$MYSQL_USER
15-
- WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
16-
- WORDPRESS_DB_NAME=$MYSQL_DATABASE
14+
- WORDPRESS_DB_USER=root
15+
- WORDPRESS_DB_PASSWORD=$MYSQL_ROOT_PASSWORD
1716
volumes:
18-
- ./jquery-wp-content:/var/www/html/jquery-wp-content
17+
- ./jquery-wp-content:/var/www/html/wp-content
1918
- ./uploads:/var/www/html/wp-content/uploads:rw
2019
- ./wp-config.php:/var/www/html/wp-config.php
2120
- ./ssl:/etc/apache2/ssl
@@ -28,14 +27,13 @@ services:
2827
- jquerynet
2928

3029
jquerydb:
31-
image: mysql
30+
image: mariadb:10.11
3231
container_name: jquerydb
3332
restart: unless-stopped
3433
env_file:
3534
- .env
3635
volumes:
3736
- jquerydbdata:/var/lib/mysql
38-
command: '--default-authentication-plugin=mysql_native_password'
3937
ports:
4038
- "3306:3306"
4139
networks:

jquery-wp-content

Submodule jquery-wp-content updated 82 files

wp-config-sample.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99

1010
define( 'JQUERY_STAGING', true );
1111
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 );
1215

1316
// WordPress debugging mode (enables PHP E_NOTICE and WordPress notices)
1417
define( 'WP_DEBUG', (bool) JQUERY_STAGING );
1518

16-
// Set the uploads directory so docker can write to it
17-
define( 'UPLOADS', 'wp-content/uploads' );
18-
1919
/*
2020
* Database Settings
2121
*/
2222

2323
// ** MySQL settings - You can get this info from your web host ** //
2424
/** The name of the database for WordPress */
25-
define('DB_NAME', getenv('WORDPRESS_DB_NAME'));
25+
define('DB_NAME', 'wordpress_' . strtr( JQUERY_LIVE_SITE, [ '.' => '_' ]);
2626

2727
/** MySQL database username */
2828
define('DB_USER', getenv('WORDPRESS_DB_USER'));
@@ -62,12 +62,5 @@
6262

6363
/* That's all, stop editing! Happy blogging. */
6464

65-
/** Absolute path to the WordPress directory. */
66-
if ( !defined('ABSPATH') )
67-
define('ABSPATH', dirname(__FILE__) . '/');
68-
69-
/** jQuery.com configuration file */
70-
require( dirname( __FILE__ ) . '/jquery-wp-content/config.php' );
71-
7265
/** Sets up WordPress vars and included files. */
73-
require_once(ABSPATH . 'wp-settings.php');
66+
require_once __DIR__ . '/wp-settings.php' ;

0 commit comments

Comments
 (0)