-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for plugins and website preinstallation
- Loading branch information
Maya Baya
committed
May 22, 2022
1 parent
26e17a6
commit 86b3d24
Showing
5 changed files
with
121 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,13 @@ ENV AUTO_UPDATE_CRON="0 5 * * TUE" \ | |
PHP_UPLOAD_MAX_FILESIZE="32M" \ | ||
PHP_MEMORY_LIMIT="128M" \ | ||
HEALTH_CHECK_ALLOWED_SUBNET="" \ | ||
FORCE_UPGRADE=false | ||
FORCE_UPGRADE=false \ | ||
ENABLED_PLUGINS="" \ | ||
WP_PREINSTALL=false \ | ||
WP_SITE_URL=example.org \ | ||
WP_SITE_ADMIN_LOGIN=admin \ | ||
WP_SITE_ADMIN_PASSWORD=riotkit \ | ||
[email protected] | ||
|
||
# p2 (jinja2) | ||
RUN wget https://github.com/wrouesnel/p2cli/releases/download/r13/p2-linux-x86_64 -O /usr/bin/p2 && chmod +x /usr/bin/p2 | ||
|
@@ -73,7 +79,8 @@ RUN cat /etc/group | grep -v "www-data" > /etc/group.tmp \ | |
# add entrypoints | ||
ADD container-files/entrypoint-riotkit.sh /usr/local/bin/ | ||
ADD container-files/entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
RUN chmod +x /usr/local/bin/entrypoint-riotkit.sh /usr/local/bin/docker-entrypoint.sh | ||
ADD container-files/install-plugins-first-time.sh /usr/local/bin/install-plugins-first-time.sh | ||
RUN chmod +x /usr/local/bin/entrypoint-riotkit.sh /usr/local/bin/docker-entrypoint.sh /usr/local/bin/install-plugins-first-time.sh | ||
|
||
# high user id number should be more compatible with OpenShift | ||
USER 65161 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ Hardened version of official Wordpress container, with special support for Kuber | |
- Non-root container | ||
- Free from Supervisord, using lightweight [multirun](https://github.com/nicolas-van/multirun) instead | ||
- Runtime NGINX and PHP configuration to adjust things like `memory_limit`, `error_reporting` or `post_max_size` | ||
- Preconfiguration of admin account, website name and list of installed plugins | ||
- Possible to upgrade Wordpress together with docker container | ||
|
||
Roadmap | ||
------- | ||
|
@@ -77,6 +79,7 @@ services: | |
AUTO_UPDATE_CRON: "0 5 * * SAT" | ||
XMLRPC_DISABLED: "true" | ||
DISABLE_DIRECT_CONTENT_PHP_EXECUTION: "false" | ||
ENABLED_PLUGINS: "amazon-s3-and-cloudfront" | ||
|
||
# basic auth on administrative endpoints | ||
BASIC_AUTH_ENABLED: "true" | ||
|
@@ -91,6 +94,64 @@ services: | |
|
||
``` | ||
|
||
Automating installation | ||
----------------------- | ||
|
||
You can skip installation wizard by installing WordPress on container startup. | ||
This container uses `wp-cli` to install WordPress and plugins allowing you to prepare a fully automated website. | ||
|
||
**Example configuration:** | ||
```yaml | ||
WP_PREINSTALL: true | ||
WP_SITE_URL: example.org | ||
WP_SITE_ADMIN_LOGIN: admin | ||
WP_SITE_ADMIN_PASSWORD: riotkit | ||
WP_SITE_ADMIN_EMAIL: [email protected] | ||
|
||
# NOTICE: The plugins will be installed right after WordPress installation is finished, | ||
# this means that when `WP_PREINSTALL=false`, then the entrypoint will wait for user | ||
# to complete the installation wizard, then the plugins will be installed | ||
ENABLED_PLUGINS: "amazon-s3-and-cloudfront,classic-editor" | ||
``` | ||
**Example log:** | ||
```bash | ||
>> Checking if autoupdate should be scheduled... [scheduling at '0 5 * * TUE'] | ||
>> Writing to basic auth file - /opt/htpasswd | ||
Adding password for user riotkit | ||
>> Rendering configuration files... | ||
>> Installing Wordpress | ||
>> UID=65161, GID=65161 | ||
WordPress not found in /var/www/riotkit - copying now... | ||
sending incremental file list | ||
index.php | ||
liveness.php | ||
readiness.php | ||
... | ||
wp-includes/widgets/class-wp-widget-text.php | ||
|
||
sent 58,545,704 bytes received 54,312 bytes 39,066,677.33 bytes/sec | ||
total size is 58,341,389 speedup is 1.00 | ||
Complete! WordPress has been successfully copied to /var/www/riotkit | ||
No 'wp-config.php' found in /var/www/riotkit, but 'WORDPRESS_...' variables supplied; copying 'wp-config-docker.php' (WORDPRESS_DB_HOST WORDPRESS_DB_NAME WORDPRESS_DB_PASSWORD WORDPRESS_DB_USER) | ||
Success: WordPress installed successfully. | ||
>> Installing plugin 'amazon-s3-and-cloudfront' | ||
Installing WP Offload Media Lite for Amazon S3, DigitalOcean Spaces, and Google Cloud Storage (2.6.2) | ||
Downloading installation package from https://downloads.wordpress.org/plugin/amazon-s3-and-cloudfront.2.6.2.zip... | ||
Unpacking the package... | ||
Installing the plugin... | ||
Plugin installed successfully. | ||
Success: Installed 1 of 1 plugins. | ||
>> Installing plugin 'classic-editor' | ||
Installing Classic Editor (1.6.2) | ||
Downloading installation package from https://downloads.wordpress.org/plugin/classic-editor.1.6.2.zip... | ||
Unpacking the package... | ||
Installing the plugin... | ||
Plugin installed successfully. | ||
Success: Installed 1 of 1 plugins. | ||
``` | ||
From authors | ||
------------ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
installPlugins() { | ||
IFS=, read -ra plugins <<< "${ENABLED_PLUGINS}" | ||
for plugin in "${plugins[@]}"; do | ||
echo " >> Installing plugin '${plugin}'" | ||
wp plugin install "${plugin}" || return 1 | ||
done | ||
} | ||
|
||
if [[ "${1}" == "no-wait" ]]; then | ||
installPlugins | ||
else | ||
while [[ ! -f /var/www/riotkit/wp-content/.plugins-installed ]]; do | ||
if wp core is-installed; then | ||
if installPlugins; then | ||
echo " >> Plugins installed" | ||
break | ||
else | ||
echo " !!! Plugins installation failed" | ||
fi | ||
else | ||
echo " ... Waiting for Wordpress to be installed" | ||
fi | ||
|
||
sleep 20 | ||
done | ||
|
||
echo ">> Fuckwork mode on" | ||
sleep 999999999 | ||
fi |