|
1 | | -Automated set up utilities for WordPress. |
| 1 | +Automated set up utilities for [WordPress]. |
2 | 2 |
|
3 | 3 | WordPress is set up with a non-root user. |
4 | 4 |
|
5 | 5 | Volumes for the docroot and wp-content/uploads directories are configured. |
6 | 6 |
|
| 7 | +The installation is hardcoded to `/var/www`. |
| 8 | + |
7 | 9 | # Usage |
8 | 10 |
|
9 | | -To automatically setup WP use two containers: |
| 11 | +See `docker-compose.yml` for a usage example. |
10 | 12 |
|
11 | | - # docker-compose.yml |
12 | | - wp-setup: |
13 | | - image: nickbreen/wp-setup |
14 | | - environment: |
15 | | - # yadda, see below |
| 13 | +`attach` or `exec` (etc) into the container and execute `setup`. |
16 | 14 |
|
17 | | -# Configuration |
| 15 | + docker exec -itu wp CONTAINER bash -l -c 'setup' |
18 | 16 |
|
19 | | -The database configuration can be specified explicitly with: |
| 17 | +This image provides and uses [WP-CLI]. |
20 | 18 |
|
21 | | -- ```WP_DB_HOST``` |
22 | | -- ```WP_DB_PORT``` |
23 | | -- ```WP_DB_NAME``` |
24 | | -- ```WP_DB_USER``` |
25 | | -- ```WP_DB_PASSWORD``` |
26 | | -- ```WP_DB_PREFIX``` |
| 19 | +## Download |
27 | 20 |
|
28 | | -If any are omitted then values are inferred from the linked ```:mysql``` container, otherwise sensible defaults are used. |
| 21 | +The version and a locale can be specified with environment variables. |
29 | 22 |
|
30 | | -Variable | Value inferred from | Default |
31 | | --------------------- | ------------------------------ | --------- |
32 | | -```WP_DB_NAME``` | ```MYSQL_ENV_MYSQL_DATABASE``` | wordpress |
33 | | -```WP_DB_USER``` | ```MYSQL_ENV_MYSQL_USER``` | wordpress |
34 | | -```WP_DB_PASSWORD``` | ```MYSQL_ENV_MYSQL_PASSWORD``` | wordpress |
35 | | -```WP_DB_HOST``` | ```MYSQL_PORT_3306_TCP_ADDR``` | mysql |
36 | | -```WP_DB_PORT``` | ```MYSQL_PORT_3306_TCP_PORT``` | 3306 |
37 | | -```WP_DB_PREFIX``` | N/A | wp_ |
| 23 | +| Variable | Example | Default |
| 24 | +|------------|---------|--------- |
| 25 | +| WP_VERSION | 4.4.2 | Latest |
| 26 | +| WP_LOCALE | en_NZ | en_US |
38 | 27 |
|
39 | | -```--extra-php``` is supported with the ```WP_EXTRA_PHP``` environment variable. E.g. |
| 28 | +## Configuration |
40 | 29 |
|
41 | | - WP_EXTRA_PHP: | |
42 | | - define('DISABLE_WP_CRON', true); |
| 30 | +The database configuration can be specified explicitly with environment variables. |
43 | 31 |
|
44 | | -## Installation |
| 32 | +If any are omitted then values are inferred from the linked ```:mysql``` |
| 33 | +container, otherwise sensible defaults are used. |
45 | 34 |
|
46 | | -The initial DB is installed, if not already installed in the DB, using the variables; each has a useless default value, so make sure you set them: |
47 | | -- ```WP_LOCALE``` (default ```en_NZ```) |
48 | | -- ```WP_URL``` |
49 | | -- ```WP_TITLE``` |
50 | | -- ```WP_ADMIN_USER``` |
51 | | -- ```WP_ADMIN_PASSWORD``` |
52 | | -- ```WP_ADMIN_EMAIL``` |
| 35 | +| Variable | Value inferred from | Default |
| 36 | +|----------------| -------------------------| --------- |
| 37 | +| WP_DB_NAME | MYSQL_ENV_MYSQL_DATABASE | wordpress |
| 38 | +| WP_DB_USER | MYSQL_ENV_MYSQL_USER | wordpress |
| 39 | +| WP_DB_PASSWORD | MYSQL_ENV_MYSQL_PASSWORD | wordpress |
| 40 | +| WP_DB_HOST | MYSQL_PORT_3306_TCP_ADDR | mysql |
| 41 | +| WP_DB_PORT | MYSQL_PORT_3306_TCP_PORT | 3306 |
| 42 | +| WP_DB_PREFIX | N/A | wp_ |
53 | 43 |
|
54 | | -## Themes and Plugins |
| 44 | +`--extra-php` is supported with the `WP_EXTRA_PHP` environment variable. E.g. |
55 | 45 |
|
56 | | -Themes and plugins can be installed from the WordPress.org repository, from a URL to the theme's or plugin's ZIP file. I.e.: |
| 46 | + WP_EXTRA_PHP: | |
| 47 | + define('DISABLE_WP_CRON', true); |
57 | 48 |
|
58 | | -Each theme or plugin is on its own line. |
| 49 | +## Installation |
59 | 50 |
|
60 | | - WP_THEMES: | |
61 | | - theme-slug |
62 | | - http://theme.domain/theme-url.zip |
| 51 | +The initial DB is installed, if not already installed in the DB, using the |
| 52 | +following variables; the setup script will complain if any are unset. |
63 | 53 |
|
64 | | - WP_PLUGINS: | |
65 | | - plugin-slug |
66 | | - https://plugin.domain/plugin-url.zip |
| 54 | +| Variable | Example | Default |
| 55 | +|-------------------|---------------------|--------- |
| 56 | +| WP_LOCALE | en_NZ | en_US |
| 57 | +| WP_URL | http://example.com | |
| 58 | +| WP_TITLE | Example Title | |
| 59 | +| WP_ADMIN_EMAIL | admin@example.com | |
| 60 | +| WP_ADMIN_USER | admin | |
| 61 | +| WP_ADMIN_PASSWORD | | |
67 | 62 |
|
68 | | -Themes and plugins can also be installed from [Bitbucket] (OAuth 1.0a supported for private repositories) and [GitHub] (HTTP Basic Auth using personal access tokens for private repositories): |
| 63 | +## Multisite |
69 | 64 |
|
70 | | - BB_KEY: "BitBucket API OAuth Key" |
71 | | - BB_SECRET: "BitBucket API OAuth Secret" |
72 | | - BB_PLUGINS: | |
73 | | - account/repo [tag] |
74 | | - BB_THEMES: | |
75 | | - account/repo [tag] |
76 | | - GH_TOKEN: username:token |
77 | | - GH_THEME: | |
78 | | - CherryFramework/CherryFramework |
| 65 | +Multisite is supported, it is enabled when the `WP_SUBDOMAINS` environment |
| 66 | +variable is set. |
79 | 67 |
|
80 | | -[Bitbucket]: https://bitbucket.com "Bitbucket" |
81 | | -[GitHub]: https://github.com "GitHub" |
| 68 | +| Variable | Example |
| 69 | +|---------------|--------- |
| 70 | +| WP_SUBDOMAINS | "yes" |
82 | 71 |
|
83 | | -## Options |
| 72 | +Path-based multisites are not supported. |
84 | 73 |
|
85 | | -Any WordPress options can be set as JSON using ```WP_OPTIONS```. E.g. |
| 74 | +A domain mapping plugin is not required. Use the convenience function to |
| 75 | +register a new site. |
86 | 76 |
|
87 | | - WP_OPTIONS: | |
88 | | - timezone_string "Pacific/Auckland" |
89 | | - some_complex_option {"access_key_id":"...","secret_access_key":"..."} |
| 77 | + WP_COMMANDS: | |
| 78 | + new_site sitea sitea.dev http://sitea.dev "Site A" |
| 79 | + wp --url=http://sitea.dev theme activate twentyfourteen |
90 | 80 |
|
91 | | -Simple strings must be quoted. |
| 81 | +## Themes and Plugins |
92 | 82 |
|
93 | | -To set non-JSON options, use ```WP_COMMANDS```. |
| 83 | +Themes and plugins can be installed from the WordPress.org repository, from a |
| 84 | +URL to the theme's or plugin's ZIP file using `WP_COMMANDS`; e.g.: |
94 | 85 |
|
95 | | -## Arbitrary WP-CLI Commands |
| 86 | + WP_COMMANDS: | |
| 87 | + wp theme install theme-slug --version=1.2.3 |
| 88 | + wp theme install http://example.com/theme.zip --activate |
| 89 | + wp plugin install plugin-slug --version=1.2.3 |
| 90 | + wp plugin install https://example.com/plugin.zip |
96 | 91 |
|
97 | | -Any WP-CLI command can be executed; e.g.: |
| 92 | +Themes and plugins can also be installed from [Bitbucket] (OAuth 1.0a supported |
| 93 | +for private repositories) and [GitHub] (HTTP Basic Auth using personal access |
| 94 | +tokens for private repositories); e.g.: |
98 | 95 |
|
99 | 96 | WP_COMMANDS: | |
100 | | - rewrite structure /%postname% |
101 | | - rewrite flush |
| 97 | + wp github theme install CherryFramework/CherryFramework v3.1.5 |
| 98 | + wp github theme install CherryFramework/CherryFramework v3.1.5 --token=XXX |
| 99 | + wp bitbucket plugin install CherryFramework/cherry-plugin v3.1.5 |
| 100 | + wp bitbucket plugin install CherryFramework/cherry-plugin v3.1.5 --key=XXX --secret=XXX |
| 101 | + |
| 102 | +For both GitHub and Bitbucket the version/release tag is optional and defaults |
| 103 | +to the `latest` release, or if no releases exist, to `master`. |
| 104 | + |
| 105 | +[WP-CLI]: http://wp-cli.org |
| 106 | +[Bitbucket]: https://bitbucket.com |
| 107 | +[GitHub]: https://github.com |
| 108 | +[WordPress]: https://wordpress.org |
| 109 | + |
| 110 | +## Arbitrary Commands |
| 111 | + |
| 112 | +Any arbitrary commands can be executed, actually any commands as the |
| 113 | +value is processed by `sh`. Any environment variable prefixed with `WP_COMMANDS` |
| 114 | +will be processed. |
| 115 | + |
| 116 | + WP_COMMANDS_0: | # Install plugins |
| 117 | + wp plugin install jetpack --activate |
| 118 | + WP_COMMANDS_1: | # Configure themes |
| 119 | + wp theme activate twentyfourteen |
| 120 | + WP_COMMANDS_2: | # Set some options |
| 121 | + wp rewrite structure /%postname% |
| 122 | + wp rewrite flush |
0 commit comments