|
1 |
| -# jquery-wp-docker |
2 |
| - |
3 |
| -This repo has the necessary setup for running [jquery-wp-content](https://github.com/jquery/jquery-wp-content) in [WordPress](https://wordpress.com/) locally using [Docker](https://www.docker.com/). |
4 |
| - |
5 |
| -## Usage |
6 |
| - |
7 |
| -1. Clone this repo and its submodules |
8 |
| - |
9 |
| -```sh |
10 |
| -git clone --recursive [email protected]:jquery/jquery-wp-docker.git |
11 |
| -``` |
12 |
| - |
13 |
| -2. Copy the wp-config-sample.php file to wp-config.php |
14 |
| - |
15 |
| -```sh |
16 |
| -cp wp-config-sample.php wp-config.php |
17 |
| -``` |
18 |
| - |
19 |
| -3. Edit the wp-config.php file and set unique keys and salts using https://api.wordpress.org/secret-key/1.1/salt/. Do NOT change the `DB_` defines. |
20 |
| - |
21 |
| -```php |
22 |
| -define('AUTH_KEY', 'put your unique phrase here'); |
23 |
| -define('SECURE_AUTH_KEY', 'put your unique phrase here'); |
24 |
| -// etc. |
25 |
| -``` |
26 |
| - |
27 |
| -4. Copy .env.example to .env and edit the file to define database credentials |
28 |
| - |
29 |
| -```sh |
30 |
| -MYSQL_DATABASE=your_database_name |
31 |
| -MYSQL_ROOT_PASSWORD=your_root_password |
32 |
| -MYSQL_USER=your_database_user_name |
33 |
| -MYSQL_PASSWORD=your_database_password |
34 |
| -``` |
35 |
| - |
36 |
| -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: |
37 |
| - |
38 |
| -```sh |
39 |
| -mkcert -install |
40 |
| -``` |
41 |
| - |
42 |
| -Then, in the `ssl` directory, run: |
43 |
| - |
44 |
| -```sh |
45 |
| -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 |
46 |
| -``` |
47 |
| - |
48 |
| -Wildcards don't work for multi-level subdomains. Add each site to the list of domains. |
49 |
| - |
50 |
| -6. Run `docker compose up --build` to start the containers. |
51 |
| - |
52 |
| -7. Fill the database with the latest data from production wordpress. |
53 |
| - |
54 |
| -```sh |
55 |
| -ssh wp-01.ops.jquery.net # Your SSH key must be on the server |
56 |
| -mysqldump -u jq_wordpress -p wordpress > wordpress.sql # Credentials are in the vault |
57 |
| -``` |
58 |
| - |
59 |
| -Then, on your local machine, run: |
60 |
| - |
61 |
| -```sh |
62 |
| -scp [email protected]:/path/to/wordpress.sql . |
63 |
| -docker exec -i jquerydb mysql -u YOUR_MYSQL_USER -p YOUR_MYSQL_DATABASE < wordpress.sql |
64 |
| -``` |
65 |
| - |
66 |
| -8. A side-effect of loading data from production is that the `home` option is set. This means that the site will redirect to `jquery.com` instead of `local.jquery.com`. To fix this, set the `home` option in the `wp_options` table to `https://local.jquery.com`. |
67 |
| - |
68 |
| -```sh |
69 |
| -docker exec -it jquerydb mysql -u YOUR_MYSQL_USER -p YOUR_MYSQL_DATABASE |
70 |
| -``` |
71 |
| - |
72 |
| -```sql |
73 |
| -UPDATE wp_options SET option_value = 'https://local.jquery.com' WHERE option_name = 'home'; |
74 |
| -``` |
75 |
| - |
76 |
| -This also applies to jqueryui.com, but not to the other sites. |
77 |
| - |
78 |
| -9. Visit http://local.jquery.com, or https://local.jquery.com if you created certs. |
79 |
| - |
80 |
| -## Notes |
81 |
| - |
82 |
| -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: |
83 |
| - |
84 |
| -``` |
85 |
| -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 |
86 |
| -127.0.0.1 local.jqueryui.com local.api.jqueryui.com local.blog.jqueryui.com |
87 |
| -127.0.0.1 local.jquerymobile.com local.api.jquerymobile.com local.blog.jquerymobile.com |
88 |
| -127.0.0.1 local.jquery.org local.brand.jquery.org local.contribute.jquery.org local.events.jquery.org local.meetings.jquery.org |
89 |
| -``` |
| 1 | +# jquery-wp-docker |
| 2 | + |
| 3 | +This repo has the necessary setup for running [jquery-wp-content](https://github.com/jquery/jquery-wp-content) in [WordPress](https://wordpress.com/) locally using [Docker](https://www.docker.com/). |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +1. Clone this repo and its submodules |
| 8 | + |
| 9 | +```sh |
| 10 | +git clone --recursive [email protected]:jquery/jquery-wp-docker.git |
| 11 | +``` |
| 12 | + |
| 13 | +2. Copy the wp-config-sample.php file to wp-config.php |
| 14 | + |
| 15 | +```sh |
| 16 | +cp wp-config-sample.php wp-config.php |
| 17 | +``` |
| 18 | + |
| 19 | +3. Edit the wp-config.php file and set unique keys and salts using https://api.wordpress.org/secret-key/1.1/salt/. Do NOT change the `DB_` defines. |
| 20 | + |
| 21 | +```php |
| 22 | +define('AUTH_KEY', 'put your unique phrase here'); |
| 23 | +define('SECURE_AUTH_KEY', 'put your unique phrase here'); |
| 24 | +// etc. |
| 25 | +``` |
| 26 | + |
| 27 | +4. Copy .env.example to .env and edit the file to define database credentials |
| 28 | + |
| 29 | +```sh |
| 30 | +cp .env.example .env |
| 31 | +``` |
| 32 | + |
| 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`.** |
| 55 | + |
| 56 | +6. Run `docker compose up --build` to start the containers. |
| 57 | + |
| 58 | +7. Fill the database with the latest data from production wordpress. |
| 59 | + |
| 60 | +```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 |
| 63 | +``` |
| 64 | + |
| 65 | +Then, on your local machine, run: |
| 66 | + |
| 67 | +```sh |
| 68 | +scp [email protected]:/path/to/wordpress.sql . |
| 69 | +docker exec -i jquerydb mysql -u YOUR_MYSQL_USER -p YOUR_MYSQL_DATABASE < wordpress.sql |
| 70 | +``` |
| 71 | + |
| 72 | +8. Visit http://local.jquery.com, or https://local.jquery.com if you created certs. |
| 73 | + |
| 74 | +## Notes |
| 75 | + |
| 76 | +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: |
| 77 | + |
| 78 | +``` |
| 79 | +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 |
| 80 | +127.0.0.1 local.jqueryui.com local.api.jqueryui.com local.blog.jqueryui.com |
| 81 | +127.0.0.1 local.jquerymobile.com local.api.jquerymobile.com local.blog.jquerymobile.com |
| 82 | +127.0.0.1 local.jquery.org local.brand.jquery.org local.contribute.jquery.org local.events.jquery.org local.meetings.jquery.org |
| 83 | +``` |
0 commit comments