72 Commits

Author SHA1 Message Date
e96813bdd1 Revert "Bump docker/bake-action from 2.3.0 to 3.0.1" 2023-04-23 17:33:15 +02:00
f26a5d68e6 Merge pull request #15 from N0rthernL1ghts/dependabot/github_actions/docker/bake-action-3.0.1
Bump docker/bake-action from 2.3.0 to 3.0.1
2023-04-22 22:48:59 +02:00
dependabot[bot]
eed560bb99 Bump docker/bake-action from 2.3.0 to 3.0.1
Bumps [docker/bake-action](https://github.com/docker/bake-action) from 2.3.0 to 3.0.1.
- [Release notes](https://github.com/docker/bake-action/releases)
- [Commits](https://github.com/docker/bake-action/compare/v2.3.0...v3.0.1)

---
updated-dependencies:
- dependency-name: docker/bake-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-19 23:01:03 +00:00
5b75b4119e Use variable for REGISTRY_CACHE 2023-04-11 12:59:28 +02:00
4d712f7861 Fix link to packages 2023-04-11 03:02:19 +02:00
83e0bc5924 Link packages 2023-04-11 03:01:17 +02:00
04f0dc4d93 Improve formatting, order and docs 2023-04-09 21:58:01 +02:00
ec520c2e42 Use variable for REGISTRY_CACHE 2023-04-09 21:46:50 +02:00
0a225eedd7 Add deprecation notice for docker.io images 2023-04-09 21:09:15 +02:00
9a2794d584 Fix double tagging 2023-04-08 19:46:25 +02:00
e39555b0b1 Simlify, and refactor to use functions
This should greatly reduce duplication and overall size
2023-04-08 19:39:44 +02:00
a6080cbef0 Use SHA-1 instead of MD5 for cache tags 2023-04-08 16:49:58 +02:00
7e55f47ac6 Implement registry cache as additional cache for all builds 2023-04-08 16:39:12 +02:00
f8beef6bf4 Attempt using both gha and registry cache for 6.1.1 2023-04-08 15:52:34 +02:00
cad36f6e7e Fix some old stuff 2023-04-06 21:36:33 +02:00
a50ce69fc0 Reformat and cleanup 2023-04-06 21:32:28 +02:00
6f165400a4 Apply formatting 2023-04-06 08:40:00 +02:00
f57537dfcf Define more org.opencontainers labels 2023-04-06 03:30:03 +02:00
7c8fa6cfc8 Add org.opencontainers.image.source label 2023-04-06 00:33:24 +02:00
d236f0ba51 Update ghcr.io namespace 2023-04-06 00:01:28 +02:00
69c43a5caa Add ghcr.io tags and push 2023-04-05 23:14:50 +02:00
1357f2fec3 Add step for authorizing to ghcr 2023-04-05 22:54:20 +02:00
fd6fba8dc9 Trigger build 2023-04-05 19:45:00 +02:00
8a0671090e Remove empty defintion 2023-04-05 19:31:57 +02:00
f70d3d891c Use platform as part of the scope 2023-04-05 19:20:00 +02:00
fc85a1d8cb Improve caching
Inspired by: https://hackernoon.com/one-dockerfile-is-all-it-takes-how-i-fell-in-love-with-bake
2023-04-05 19:09:34 +02:00
23192aaa94 Update WordPress 6.1.1 -> 6.2.0 2023-04-02 20:32:47 +02:00
e184127d38 Update formatting 2023-04-02 20:31:39 +02:00
aeb39d0f13 Use target _blank 2023-04-02 20:25:19 +02:00
250227f3e1 Refactor: Change structure. Remove strictness 2023-03-22 03:24:27 +01:00
90f38805fa Rename 20-install-plugins -> 20-install-resources (more generic) 2023-03-22 02:38:07 +01:00
ef47e1b2b9 Add wp-theme script for managing themes 2023-03-22 02:35:46 +01:00
1b62dba10a Add delete functionality 2023-03-22 02:34:13 +01:00
f79da27583 Update documentation for plugins installer
Also provide example of extending this image
2023-03-21 12:59:44 +01:00
53ab34b35e Rename to CONCURRENCY_LIMIT to WP_PLUGINS_INSTALL_CONCURRENCY and set default value to 5 2023-03-21 12:48:08 +01:00
47ba7873f1 Implement proccess locking for plugin installer in order to prevent script from running on multiple instances at the same time 2023-03-21 08:06:47 +01:00
879df6c042 Update tests and patch-util Docker image to use PHP 8.1 2023-03-21 02:12:31 +01:00
8df891a400 Refactor plugin installer
- Fixes issue where installation is dependent of existence of working database connection

- Overall improvements

- Move out some logic to wp-plugin script

- Use curl to download plugins, instead of wp cli
2023-03-21 01:40:07 +01:00
c26a0afd1f Define concurrency limit with variable 2023-03-17 21:14:26 +01:00
aa68d5ba82 Limit concurrency to 4 plugins per batch
This should help avoid concurrency related issues, sacrificing a little bit of performance
2023-03-17 21:00:06 +01:00
e2ed315ff2 Use indent of 4 spaces 2023-03-17 19:43:44 +01:00
a8f2aadab2 Trigger build - base image update 2023-03-17 03:16:04 +01:00
f387ec0773 Revert "Improve plugin installer reliability"
This reverts commit f81ec4c67e.
2023-03-15 02:54:53 +01:00
c41860611d Revert "Mark PLUGIN_PATH as mandatory variable"
This reverts commit 4fc19fa5e7.
2023-03-15 02:54:31 +01:00
4fc19fa5e7 Mark PLUGIN_PATH as mandatory variable 2023-03-15 02:38:24 +01:00
f81ec4c67e Improve plugin installer reliability 2023-03-15 02:33:50 +01:00
f0ce5dae9e Trigger build - refresh image 2023-03-06 20:02:00 +01:00
924a9c9304 Merge pull request #13 from N0rthernL1ghts/dependabot/github_actions/lewagon/wait-on-check-action-1.3.1
Bump lewagon/wait-on-check-action from 1.2.0 to 1.3.1
2023-03-05 15:19:56 +01:00
dependabot[bot]
0b69603a10 Bump lewagon/wait-on-check-action from 1.2.0 to 1.3.1
Bumps [lewagon/wait-on-check-action](https://github.com/lewagon/wait-on-check-action) from 1.2.0 to 1.3.1.
- [Release notes](https://github.com/lewagon/wait-on-check-action/releases)
- [Commits](https://github.com/lewagon/wait-on-check-action/compare/v1.2.0...v1.3.1)

---
updated-dependencies:
- dependency-name: lewagon/wait-on-check-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-16 23:02:59 +00:00
2fd2e0d6aa Trigger build - base image change 2023-02-01 01:52:03 +01:00
fcd9719d6b Merge pull request #12 from N0rthernL1ghts/dependabot/github_actions/docker/build-push-action-4
Bump docker/build-push-action from 3 to 4
2023-01-31 01:41:21 +01:00
dependabot[bot]
89fb3fa6a0 Bump docker/build-push-action from 3 to 4
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3 to 4.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-30 22:17:15 +00:00
e398d3a71a Fix issue where wp-config.php is not initialized 2023-01-24 02:17:20 +01:00
64722d5b6c Add healthcheck script and mechanism to make unhealthy if WP install integrity is compromised 2023-01-24 01:42:53 +01:00
fedfaeafc4 Apply patch during build time 2023-01-24 01:24:46 +01:00
bb3f62ef10 Initialize WordPress during build time 2023-01-23 23:03:06 +01:00
a72f393567 Remove nginx leftover 2023-01-23 22:46:31 +01:00
705a2d505d Remove built-in and use official docker-optimized wp-config.php instead 2023-01-23 22:32:36 +01:00
dd43a2e929 Remove WEB_ROOT env variable (legacy) 2023-01-23 19:50:30 +01:00
e5ad0997f6 Trigger build - base image change 2023-01-23 19:44:54 +01:00
4edf0ee410 Trigger build - base image change 2023-01-23 17:33:02 +01:00
fdb3c6727e Replace NGINX + PHP-FPM combo with NGINX Unit application server 2023-01-22 20:07:53 +01:00
824994c6b7 Retire PHP7.4. Welcome PHP8.1 2023-01-21 03:03:19 +01:00
3377076391 Remove deprecated instruction 2023-01-21 03:00:48 +01:00
88b4e4514a Add http.d directory
Missing since e344128779
2023-01-21 02:59:27 +01:00
149e34bcd2 Add maintainer label 2023-01-21 02:51:41 +01:00
0d454a15d9 Update nlss/base-alpine:3.14 -> nlss/base-alpine:3.16 2023-01-20 18:03:18 +01:00
e344128779 Remove remaining ties to nlss/php-nginx:7.4 image 2023-01-20 18:00:51 +01:00
6d526d71e1 Remove rootfs/usr/local/etc/php-fpm.d/ ties to nlss/php-nginx:7.4 image 2023-01-20 17:40:55 +01:00
550bcea00d Remove /etc/services.d/php-fpm/ ties to nlss/php-nginx:7.4 image 2023-01-20 17:38:08 +01:00
68da285e90 Remove /etc/cont-init.d ties to nlss/php-nginx:7.4 image 2023-01-20 17:32:48 +01:00
a1563b89f4 Merge pull request #11 from N0rthernL1ghts/other/deprecate-old-versions
Deprecate WordPress versions prior to 5.9
2023-01-20 17:05:16 +01:00
22 changed files with 734 additions and 440 deletions

View File

@@ -27,9 +27,16 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.PAT_TOKEN}}
-
name: Await successful tests
uses: lewagon/wait-on-check-action@v1.2.0
uses: lewagon/wait-on-check-action@v1.3.1
with:
ref: ${{ github.sha }}
check-name: tests
@@ -40,7 +47,4 @@ jobs:
uses: docker/bake-action@v2.3.0
with:
files: build/docker-bake.hcl
push: true
set: |
*.cache-from=type=gha,scope=wordpress
*.cache-to=type=gha,scope=wordpress,mode=max
push: true

View File

@@ -20,7 +20,7 @@ jobs:
-
name: "Build tests-util image"
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
id: build
with:
context: build/tests-util/

View File

@@ -1,8 +1,10 @@
ARG PHP_VERSION=7.4
ARG PHP_VERSION=8.1
ARG WP_VERSION=6.1.0
# WP CLI
# WordPress resources
FROM --platform=${TARGETPLATFORM} wordpress:cli-php${PHP_VERSION} AS wp-cli
FROM --platform=${TARGETPLATFORM} wordpress:${WP_VERSION}-php${PHP_VERSION}-fpm-alpine AS wp-src
# Build rootfs
@@ -11,68 +13,46 @@ FROM scratch AS rootfs
# Install wp-cli
COPY --from=wp-cli ["/usr/local/bin/wp", "/usr/local/bin/wp-cli"]
# Install attr utility
COPY --from=nlss/attr ["/usr/local/bin/attr", "/usr/local/bin/"]
# Add crond service
COPY --from=nlss/base-alpine:3.14 ["/etc/services.d/cron/", "/etc/services.d/cron/"]
# Add container init tasks
COPY --from=nlss/php-nginx:7.4 ["/etc/cont-init.d/", "/etc/cont-init.d/"]
# Add php-fpm configuration
COPY --from=nlss/php-nginx:7.4 ["/usr/local/etc/php-fpm.d/", "/usr/local/etc/php-fpm.d/"]
# Add php-fpm service
COPY --from=nlss/php-nginx:7.4 ["/etc/services.d/php-fpm/", "/etc/services.d/php-fpm/"]
# Add nginx service and configuration
COPY --from=nlss/php-nginx:7.4 ["/etc/services.d/nginx/", "/etc/services.d/nginx/"]
COPY --from=nlss/php-nginx:7.4 ["/etc/nginx/", "/etc/nginx/"]
COPY --from=nlss/php-nginx:7.4 ["/var/log/nginx/", "/var/log/nginx/"]
COPY --from=nlss/php-nginx:7.4 ["/var/www/", "/var/www/"]
# Install gomplate
COPY --from=hairyhenderson/gomplate:v3.10.0-alpine ["/bin/gomplate", "/usr/local/bin/"]
# Install s6 supervisor
COPY --from=nlss/s6-rootfs:2.2 ["/", "/"]
# Overlay
COPY ["./rootfs/", "/"]
# Configuration and patches
ARG WP_VERSION
COPY ["wp-config.php", "/var/www/html/"]
# Copy WordPress source from the official image
COPY --from=wp-src ["/usr/src/wordpress/", "/var/www/html/"]
COPY ["patches/${WP_VERSION}/wp-admin-update-core.patch", "/etc/wp-mods/"]
# Stage 3 - Final
FROM --platform=${TARGETPLATFORM} wordpress:${WP_VERSION}-php${PHP_VERSION}-fpm-alpine
FROM --platform=${TARGETPLATFORM} nlss/wordpress-unit-base:1.0.0
RUN apk add --update --no-cache patch less mysql-client tzdata
RUN apk add --update --no-cache patch
COPY --from=rootfs ["/", "/"]
RUN mv /etc/nginx/conf.d /etc/nginx/http.d \
&& apk add --update --no-cache nginx \
&& echo "*/5 * * * * /usr/local/bin/wp cron event run --due-now" >> /etc/crontabs/www-data \
&& chmod a+x /usr/local/bin/wp
RUN set -eux \
&& chmod a+x /usr/local/bin/wp \
&& mv "/var/www/html/wp-config-docker.php" "/var/www/html/wp-config.php" \
&& wp-apply-patch "/etc/wp-mods/wp-admin-update-core.patch" "/var/www/html/wp-admin/update-core.php" "true"
ARG WP_VERSION
ENV WP_VERSION="${WP_VERSION}"
ARG WP_LOCALE="en_US"
ENV WP_LOCALE=${WP_LOCALE}
ENV VIRTUAL_HOST=your-domain.com
ENV S6_KEEP_ENV=1
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2
ENV ENFORCE_DISABLE_WP_UPDATES=true
ENV WP_CLI_DISABLE_AUTO_CHECK_UPDATE=true
ENV CRON_ENABLED=true
ENV WEB_ROOT=html
WORKDIR "/var/www/${WEB_ROOT}/"
VOLUME ["/root/.wp-cli", "/var/www/${WEB_ROOT}", "/var/www/${WEB_ROOT}/wp-content"]
WORKDIR "/var/www/html/"
VOLUME ["/root/.wp-cli", "/var/www/html/wp-content"]
LABEL maintainer="Aleksandar Puharic <aleksandar@puharic.com>" \
org.opencontainers.image.documentation="https://github.com/N0rthernL1ghts/wordpress/wiki" \
org.opencontainers.image.source="https://github.com/N0rthernL1ghts/wordpress" \
org.opencontainers.image.description="nginx-unit Powered WordPress ${WP_VERSION} - Build ${TARGETPLATFORM}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.version="${WP_VERSION}"
ENTRYPOINT ["/init"]
EXPOSE 80/TCP

View File

@@ -1,5 +1,5 @@
# wordpress
WorPress docker image, powered by nginx/php-fpm combo and managed by s6 supervisor.
WordPress docker image, powered by s6 supervised nginx unit.
Attempt to fix several of WordPress anti-patterns in ready to deploy container
@@ -11,17 +11,34 @@ Attempt to fix several of WordPress anti-patterns in ready to deploy container
* PHP7.4 reached end-of-life on 2022-11-28 and should not be used.
* Old images will remain, but will receive no further updates, until their eventual removal. Usage is not recommended.
* This decision will make build stack significantly lighter, ensuring much faster future builds
- 2023-01-21 Retirement of PHP7.4. The king is dead, long live the king!
- 2023-01-22 Replace NGINX + PHP-FPM combo with NGINX Unit
* Split and rebase image and rework build
* This is breaking change affecting all images
* If your setup was vanilla, it should work out of the box
* If you need nginx, you can set it up as a reverse proxy
* NGINX Unit is modern application server, replacing old PHP-FPM
* Independent benchmarks have show that NGINX Unit can handle much higher load and remain stable
- 2023-01-23 WordPress is no longer installed during runtime and it's bundled into the image
* This renders WP_LOCALE environment variable useless
* Instead, you will be offered to select locale during the first setup
- 2023-04-09 Deprecation of docker.io hosted images. We're moving to ghcr.io.
* This is due to Docker Hub's sunsetting of free teams. See docker/hub-feedback#2314
* If you are using nlss/wordpress images, you should switch to ghcr.io/n0rthernl1ghts/wordpress
* nlss/wordpress images will be removed in May. Further usage is not recommended, although we'll keep them up to date until then.
#### Public builds (docker)
See: [packages](../../pkgs/container/wordpress)
You can use public build:
```
nlss/wordpress
ghcr.io/n0rthernl1ghts/wordpress:latest
```
You can also use specific version of WordPress:
```
nlss/wordpress:6.1.0
ghcr.io/n0rthernl1ghts/wordpress:6.2.0
```
Replace version number with desired version, eg. 6.0.2.
@@ -33,21 +50,56 @@ WARNING: This feature is experimental and can fail. Proceed with caution
This container can install plugins during container startup defined in environment variable WORDPRESS_PLUGIN_LIST
If environment variable is left empty, or undefined, installer will skip.
If environment variable is left empty, or undefined, installer will skip.<br/>
Consider using custom image with plugins pre-installed in order to speed up container startup, and follow the best practices.
Plugins are not activated automatically; This is intentional.
Usage example:
```
# Notice that specific version can be defined
WORDPRESS_PLUGIN_LIST=akismet:4.1.8 two-factor
WP_PLUGINS_INSTALL_CONCURRENCY=10
```
`WP_PLUGINS_INSTALL_CONCURRENCY` is optional, and defines how many plugins can be installed in parallel. Default is 5. <br/>
If you have a lot of plugins, you can increase this value to speed up installation, but be aware that this can cause issues, such as overloaded network connection, or even server overload. <br/>
You should not set this value to value higher than number of CPU threads ( * 1.5 ).
Caveats:
* If plugin was previously installed, and not defined on the list, it will NOT be removed.
* If plugin install fails, container will exit with error
* Plugins are not activated automatically; This is intentional.
* If container startup speed is crucial (eg. start-on-demand ), don't use this feature, as it will block container startup until all plugins are installed.
#### Extending image
You can extend this image and install plugins during build time, using `wp-plugin` script. <br/>
Example:
```Dockerfile
FROM ghcr.io/n0rthernl1ghts/wordpress:6.2.0 AS wp-plugins-installer
RUN set -eux \
&& export WP_PLUGINS_PATH="/var/www/html/wp-content/plugins" \
&& wp-plugin download akismet 4.1.8 \
&& wp-plugin download two-factor \
&& wp-plugin download wp-mail-smtp
# Final image
FROM ghcr.io/n0rthernl1ghts/wordpress:6.2.0
# Example:
# - Install ext-redis with pecl
# - Enable ext-redis
# - Remove pear/pecl cache
# - Put production-ready php.ini in use
RUN set -eux \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& rm -rf /tmp/pear \
&& cp "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini"
COPY --from=wp-plugins-installer ["/var/www/html/wp-content/plugins", "/var/www/html/wp-content/plugins"]
```
### TODO
* Out-of-the-box SSL support
* ~Disable core updates~
* ~Install/update plugins on the fly using wp cli (with versioning)~
* Install/update themes on the fly using wp cli (with versioning)

View File

@@ -1,5 +1,17 @@
group "default" {
targets = ["5_9_0", "5_9_1", "5_9_2", "5_9_3", "6_0_0", "6_0_1", "6_0_2", "6_0_3", "6_1_0", "6_1_1"]
targets = [
"5_9_0",
"5_9_1",
"5_9_2",
"5_9_3",
"6_0_0",
"6_0_1",
"6_0_2",
"6_0_3",
"6_1_0",
"6_1_1",
"6_2_0"
]
}
target "build-dockerfile" {
@@ -14,82 +26,147 @@ target "build-common" {
pull = true
}
target "5_9_0" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:5.9.0"]
args = {
WP_VERSION = "5.9.0"
variable "REGISTRY_CACHE" {
default = "docker.io/nlss/wordpress-cache"
}
######################
# Define the functions
######################
# Get the arguments for the build
function "get-args" {
params = [version]
result = {
WP_VERSION = version
}
}
# Get the cache-from configuration
function "get-cache-from" {
params = [version]
result = [
"type=gha,scope=${version}_${BAKE_LOCAL_PLATFORM}",
"type=registry,ref=${REGISTRY_CACHE}:${sha1("${version}-${BAKE_LOCAL_PLATFORM}")}"
]
}
# Get the cache-to configuration
function "get-cache-to" {
params = [version]
result = [
"type=gha,mode=max,scope=${version}_${BAKE_LOCAL_PLATFORM}",
"type=registry,mode=max,ref=${REGISTRY_CACHE}:${sha1("${version}-${BAKE_LOCAL_PLATFORM}")}"
]
}
# Get list of image tags and registries
# Takes a version and a list of extra versions to tag
# eg. get-tags("5.9.0", ["5", "5.9", "latest"])
function "get-tags" {
params = [version, extra_versions]
result = concat(
[
"docker.io/nlss/wordpress:${version}",
"ghcr.io/n0rthernl1ghts/wordpress:${version}"
],
flatten([
for extra_version in extra_versions : [
"docker.io/nlss/wordpress:${extra_version}",
"ghcr.io/n0rthernl1ghts/wordpress:${extra_version}"
]
])
)
}
##########################
# Define the build targets
##########################
target "5_9_0" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("5.9.0")
cache-to = get-cache-to("5.9.0")
tags = get-tags("5.9.0", [])
args = get-args("5.9.0")
}
target "5_9_1" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:5.9.1"]
args = {
WP_VERSION = "5.9.1"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("5.9.1")
cache-to = get-cache-to("5.9.1")
tags = get-tags("5.9.1", [])
args = get-args("5.9.1")
}
target "5_9_2" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:5.9.2"]
args = {
WP_VERSION = "5.9.2"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("5.9.2")
cache-to = get-cache-to("5.9.2")
tags = get-tags("5.9.2", [])
args = get-args("5.9.2")
}
target "5_9_3" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:5", "docker.io/nlss/wordpress:5.9", "docker.io/nlss/wordpress:5.9.3"]
args = {
WP_VERSION = "5.9.3"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("5.9.3")
cache-to = get-cache-to("5.9.3")
tags = get-tags("5.9.3", ["5", "5.9"])
args = get-args("5.9.3")
}
target "6_0_0" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:6.0.0"]
args = {
WP_VERSION = "6.0.0"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("6.0.0")
cache-to = get-cache-to("6.0.0")
tags = get-tags("6.0.0", [])
args = get-args("6.0.0")
}
target "6_0_1" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:6.0.1"]
args = {
WP_VERSION = "6.0.1"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("6.0.1")
cache-to = get-cache-to("6.0.1")
tags = get-tags("6.0.1", [])
args = get-args("6.0.1")
}
target "6_0_2" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:6.0.2"]
args = {
WP_VERSION = "6.0.2"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("6.0.2")
cache-to = get-cache-to("6.0.2")
tags = get-tags("6.0.2", [])
args = get-args("6.0.2")
}
target "6_0_3" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:6.0.3"]
args = {
WP_VERSION = "6.0.3"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("6.0.3")
cache-to = get-cache-to("6.0.3")
tags = get-tags("6.0.3", ["6.0"])
args = get-args("6.0.3")
}
target "6_1_0" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:6.1.0"]
args = {
WP_VERSION = "6.1.0"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("6.1.0")
cache-to = get-cache-to("6.1.0")
tags = get-tags("6.1.0", [])
args = get-args("6.1.0")
}
target "6_1_1" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
tags = ["docker.io/nlss/wordpress:6", "docker.io/nlss/wordpress:6.1", "docker.io/nlss/wordpress:6.1.1", "docker.io/nlss/wordpress:latest"]
args = {
WP_VERSION = "6.1.1"
}
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("6.1.1")
cache-to = get-cache-to("6.1.1")
tags = get-tags("6.1.1", ["6.1"])
args = get-args("6.1.1")
}
target "6_2_0" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("6.2.0")
cache-to = get-cache-to("6.2.0")
tags = get-tags("6.2.0", ["6", "6.2", "latest"])
args = get-args("6.2.0")
}

View File

@@ -25,8 +25,8 @@ echo "> Two files are now downloaded to wp-src"
echo "> Please update wp-src/mod-update-core.php with code bellow and then execute ./01-create-patch.sh"
echo ""
echo ""
echo "wp_die("
echo " __( 'Sorry, you are not allowed to update this site.' ) ."
echo " ' Click <a href=\"https://github.com/N0rthernL1ghts/wordpress/wiki/WordPress-Core-Updates\">here</a> to learn why.'"
echo ");"
echo " wp_die("
echo " __( 'Sorry, you are not allowed to update this site.' ) ."
echo " ' Click <a href=\"https://github.com/N0rthernL1ghts/wordpress/wiki/WordPress-Core-Updates\" target=\"_blank\">here</a> to learn why.'"
echo " );"
echo ""

View File

@@ -1,4 +1,4 @@
FROM wordpress:cli-php7.4 AS wordpress-builder
FROM wordpress:cli-php8.1 AS wordpress-builder
USER root
@@ -7,8 +7,8 @@ WORKDIR "/wp"
ENV UID 1000
ENV GID 1000
ENV WP_LOCALE "en_US"
ARG WP_VERSION "5.8.0"
ENV WP_VERSION "${WP_VERSION}"
ENV WP_LOCALE="en_US"
ARG WP_VERSION="6.0.2"
ENV WP_VERSION="${WP_VERSION}"
ENTRYPOINT ["/wp/entrypoint.sh"]

View File

@@ -1,4 +1,4 @@
ARG PHP_VERSION=7.4
ARG PHP_VERSION=8.1
ARG WP_VERSION=6.0.2

View File

@@ -0,0 +1,14 @@
--- update-core.php 2023-04-02 20:27:00.420010509 +0200
+++ update-core.php 2023-04-02 20:28:07.478135707 +0200
@@ -1096,6 +1096,11 @@
wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
}
+ wp_die(
+ __( 'Sorry, you are not allowed to update this site.' ) .
+ ' Click <a href="https://github.com/N0rthernL1ghts/wordpress/wiki/WordPress-Core-Updates" target="_blank">here</a> to learn why.'
+ );
+
check_admin_referer( 'upgrade-core' );
// Do the (un)dismiss actions before headers, so that they can redirect.

View File

@@ -1,74 +0,0 @@
#!/usr/bin/with-contenv bash
# Designed to replace original, overcomplicated entrypoint script from official wordpress docker repository
# Why not use already available tools instead?!
# Register exit handler
trap scriptExitHandler EXIT
function scriptExitHandler() {
LAST_EXIT_CODE=$?
if [ "${LAST_EXIT_CODE}" = "0" ]; then
echo "> Script finished successfully"
exit "${LAST_EXIT_CODE}"
fi
echo "> Script finished with an error"
exit "${LAST_EXIT_CODE}"
}
# Applies patch for making WordPress updates impossible
function disableUpdatesPatch() {
DISABLE_WP_UPDATES="${ENFORCE_DISABLE_WP_UPDATES:-true}"
if [ "${DISABLE_WP_UPDATES}" != "false" ]; then
echo "> Disabling WordPress updates..."
patch /var/www/html/wp-admin/update-core.php </etc/wp-mods/wp-admin-update-core.patch
echo "> Making the patched file read-only..."
chmod 0440 /var/www/html/wp-admin/update-core.php
fi
}
# Deletes known WordPress files
function deleteWordPress() {
echo "> Deleting WordPress installation (core files)"
# Instead of one-line find, we're taking a bit conservative approach and separating file and directory removal
# This is to ensure that this script never runs on unintended set of files as it's data loss risk
rm -rf "/var/www/${WEB_ROOT}/"{wp-includes,wp-admin}
rm -rf "/var/www/${WEB_ROOT}/"{.htaccess,index.php,license.txt,readme.html,wp-activate.php,wp-blog-header.php,wp-comments-post.php,wp-config-sample.php.php,wp-cron.php,wp-links-opml.php,wp-load.php,wp-login.php,wp-mail.php,wp-settings.php,wp-signup.php,wp-trackback.php,xmlrpc.php}
}
# Main function
function main() {
# Removes trailing zero if found
# This is required due to inconsistencies between WodPress docker image versioning and wp-cli core download
# If patch version is 0, it is not considered by wp-cli.
WP_VERSION=$(echo "${WP_VERSION:?}" | sed --expression='s/.0$//g')
WP_LOCALE="${WP_LOCALE:?}"
echo "> Verifying 'WordPress ${WP_VERSION}' installation..."
WP_INSTALLED_VERSION="$(wp core version)"
set -e
if [ -z "${WP_INSTALLED_VERSION}" ]; then
echo "> WordPress is not present"
echo "> Downloading 'WordPress ${WP_VERSION}'..."
deleteWordPress
wp core download --locale="${WP_LOCALE}" --version="${WP_VERSION}"
disableUpdatesPatch
elif [ "${WP_INSTALLED_VERSION}" != "${WP_VERSION}" ]; then
echo "> WordPress version mismatch"
echo "> Expected version: ${WP_VERSION}"
echo "> Detected version: ${WP_INSTALLED_VERSION}"
echo "> Scraping current files"
deleteWordPress
echo "> Downloading WordPress version '${WP_VERSION}'..."
wp core download --locale="${WP_LOCALE}" --version="${WP_VERSION}"
disableUpdatesPatch
else
echo "> Identified 'WordPress ${WP_VERSION}'"
fi
}
main "${@}"
exit $?

View File

@@ -0,0 +1,57 @@
#!/usr/bin/with-contenv bash
# Designed to replace original, overcomplicated entrypoint script from official wordpress docker repository
# Why not use already available tools instead?!
# Register exit handler
trap scriptExitHandler EXIT
function scriptExitHandler() {
LAST_EXIT_CODE=$?
if [ "${LAST_EXIT_CODE}" = "0" ]; then
echo "> Script finished successfully"
exit "${LAST_EXIT_CODE}"
fi
echo "> Script finished with an error"
exit "${LAST_EXIT_CODE}"
}
function reportUnhealthy() {
echo "${1:?REASON is required}" >"/tmp/.wp-unhealthy"
}
# Main function
function main() {
# Removes trailing zero if found
# This is required due to inconsistencies between WodPress docker image versioning and wp-cli core download
# If patch version is 0, it is not considered by wp-cli.
WP_VERSION=$(echo "${WP_VERSION:?}" | sed --expression='s/.0$//g')
echo "> Verifying 'WordPress ${WP_VERSION}' installation..."
WP_INSTALLED_VERSION="$(wp core version)"
set -e
rm -f "/tmp/.wp-unhealthy"
if [ -z "${WP_INSTALLED_VERSION}" ]; then
echo "> ERROR! WordPress installation does not seem to be present or valid. Continuing anyway..."
reportUnhealthy "WP_NOT_PRESENT"
return 0
elif [ "${WP_INSTALLED_VERSION}" != "${WP_VERSION}" ]; then
echo "> WARNING! WordPress version mismatch"
echo " Expected version: ${WP_VERSION}"
echo " Detected version: ${WP_INSTALLED_VERSION}"
echo "> Seems like WordPress installation got updated outside image scope"
echo " - This is dangerous as changes will not persist when container is recreated which might lead to inconsistencies between installation and the database."
echo " - You should assume that recreating the container will render the website inoperable."
echo " - Please make sure that you're running image: nlss/wordpress:${WP_VERSION}"
reportUnhealthy "WP_VERSION_MISMATCH"
return 0
else
echo "> Identified 'WordPress ${WP_VERSION}'"
fi
}
main "${@}"
exit $?

View File

@@ -1,95 +0,0 @@
#!/usr/bin/with-contenv bash
# Register exit handler
trap scriptExitHandler EXIT
function scriptExitHandler() {
LAST_EXIT_CODE=$?
if [ "${LAST_EXIT_CODE}" = "0" ]; then
echo "> Script finished successfully"
exit "${LAST_EXIT_CODE}"
fi
echo "> Script finished with an error"
exit "${LAST_EXIT_CODE}"
}
# Check if plugin installed. This is very basic check that doesn't involve database
function isPluginInstalled() {
if [ -d "${PLUGIN_PATH}" ] || [ -f "${PLUGIN_PATH}.php" ]; then
return 0
fi
return 1
}
# Install plugin
function installPlugin() {
wp plugin install "${@}" >/dev/null 2>&1
sleep 0.5
}
# Main function
function main() {
PLUGIN_LIST="${WORDPRESS_PLUGIN_LIST:-}"
PLUGIN_STRICT_INSTALL="${WORDPRESS_PLUGIN_INSTALL_STRICT:-false}"
WP_CONTENT_PATH="/var/www/${WEB_ROOT}/wp-content"
echo "> Automated WordPress Plugin Installer"
if [ -z "${PLUGIN_LIST}" ]; then
echo "> No plugins defined. Skipping installation."
return 0
fi
echo "> About to install defined plugins"
for PLUGIN_EXPR in ${PLUGIN_LIST}; do
IFS=':' read -ra PLUGIN <<<"${PLUGIN_EXPR}"
PLUGIN_PATH="${WP_CONTENT_PATH}/plugins/${PLUGIN[0]}"
if isPluginInstalled; then
echo "> Plugin '${PLUGIN[0]}' already installed and will be skipped."
continue
fi
WP_PLUGIN_INSTALL_ARGS="${PLUGIN[0]}"
if [ -n "${PLUGIN[1]}" ]; then
WP_PLUGIN_INSTALL_ARGS="${WP_PLUGIN_INSTALL_ARGS} --version=${PLUGIN[1]}"
fi
echo "> Installing plugin '${PLUGIN[0]}' version '${PLUGIN[1]}'"
installPlugin "${WP_PLUGIN_INSTALL_ARGS}" &
done
echo "> Waiting for all plugins to install..."
wait
# Plugins are installed concurrently, so we need to verify if installed, separately
echo "> About to verify install of defined plugins"
FAILED_COUNT=0
for PLUGIN_EXPR in ${PLUGIN_LIST}; do
IFS=':' read -ra PLUGIN <<<"${PLUGIN_EXPR}"
PLUGIN_PATH="${WP_CONTENT_PATH}/plugins/${PLUGIN[0]}"
if isPluginInstalled; then
echo "> Plugin '${PLUGIN[0]}' installed"
continue
fi
((FAILED_COUNT = FAILED_COUNT + 1))
echo "> Warning: Plugin '${PLUGIN[0]}' failed to install"
done
echo "> Total of ${FAILED_COUNT} plugins failed to install"
if [ "${PLUGIN_STRICT_INSTALL}" = "true" ] && [ ${FAILED_COUNT} != "0" ]; then
echo "> WORDPRESS_PLUGIN_INSTALL_STRICT is set to true. Terminating with non-zero exit code"
return 1
fi
}
main "${@}"
exit $?

View File

@@ -0,0 +1,117 @@
#!/usr/bin/with-contenv bash
# Install plugin
installPlugin() {
ARCHIVE="$(wp-plugin download "${@}" 2>/dev/null)"
if [ -z "${ARCHIVE}" ]; then
return 1
fi
wp-plugin unpack "${@}"
return $?
}
checkInstalled() {
FAILED_COUNT=0
for PLUGIN_EXPR in ${PLUGIN_LIST}; do
IFS=':' read -ra PLUGIN <<<"${PLUGIN_EXPR}"
PLUGIN_SLUG="${PLUGIN[0]}"
if wp-plugin check "${PLUGIN_SLUG}"; then
echo "> Plugin '${PLUGIN_SLUG}' installed"
continue
fi
((FAILED_COUNT = FAILED_COUNT + 1))
echo "> Warning: Plugin '${PLUGIN_SLUG}' failed to install"
done
if [ "${FAILED_COUNT}" = "0" ]; then
return 0
fi
echo "> Total of ${FAILED_COUNT} plugins failed to install"
return 1
}
# Plugins installer
function taskInstallPlugins() {
export WP_PLUGINS_PATH
CONCURRENCY_LIMIT="${WP_PLUGINS_INSTALL_CONCURRENCY:-5}"
echo "> Automated WordPress Plugins Installer"
if [ -z "${PLUGIN_LIST}" ]; then
echo "> No plugins defined. Skipping installation."
return 0
fi
echo "> About to install defined plugins"
for PLUGIN_EXPR in ${PLUGIN_LIST}; do
# Split plugin name and version
IFS=':' read -ra PLUGIN <<<"${PLUGIN_EXPR}"
PLUGIN_SLUG="${PLUGIN[0]}"
PLUGIN_VERSION="${PLUGIN[1]:-}"
if wp-plugin check "${PLUGIN_SLUG}"; then
echo "> Plugin '${PLUGIN_SLUG}' already installed and will be skipped."
continue
fi
if [ -n "${PLUGIN_VERSION}" ]; then
echo "> Installing plugin '${PLUGIN_SLUG}' version '${PLUGIN_VERSION}'"
installPlugin "${PLUGIN_SLUG}" "${PLUGIN_VERSION}" &
else
echo "> Installing plugin '${PLUGIN_SLUG}'"
installPlugin "${PLUGIN_SLUG}" &
fi
# Run maximum of X plugin installs in parallel
while [ "$(jobs | wc -l)" -ge "${CONCURRENCY_LIMIT}" ]; do
echo " Waiting for batch of ${CONCURRENCY_LIMIT} plugins to install..."
wait
done
done
echo "> Waiting for all tasks to finish..."
wait
# Plugins are installed concurrently, so we need to verify if installed, separately
echo "> About to verify install of defined plugins"
if ! checkInstalled; then
echo "> Some plugins failed to install"
return 0
fi
echo "> All plugins installed successfully"
return 0
}
# Main function
main() {
PLUGIN_LIST="${WORDPRESS_PLUGIN_LIST:-}"
WP_CONTENT_PATH="/var/www/html/wp-content"
WP_PLUGINS_PATH="${WP_CONTENT_PATH}/plugins"
echo "> Automated WordPress Resources Installer"
export WP_CONTENT_PATH
WP_PLUGINS_INSTALL_CONCURRENCY="${WP_PLUGINS_INSTALL_CONCURRENCY:-5}"
export PLUGIN_LIST WP_PLUGINS_PATH WP_PLUGINS_INSTALL_CONCURRENCY
taskInstallPlugins "${@}" &
sleep 1
echo "> Waiting for all tasks to complete"
wait
return 0
}
main "${@}"
exit $?

View File

@@ -1,40 +0,0 @@
server {
listen 80;
listen [::]:80;
server_name {{ getenv "VIRTUAL_HOST" | strings.ReplaceAll "," " " }};
set $base /var/www;
root $base/{{ getenv "WEB_ROOT" }};
# security
include nginxconfig.io/security.conf;
# logging
access_log /var/log/nginx/app-access.log;
error_log /var/log/nginx/app-error.log warn;
# index.php
index index.php;
# index.php fallback
location / {
try_files $uri $uri/ /index.php?$query_string;
}
#Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# handle .php
location ~ \.php$ {
fastcgi_intercept_errors on;
include nginxconfig.io/php_fastcgi.conf;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
# additional config
include nginxconfig.io/general.conf;
}

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
function main() {
FULL_CHECK="${1:-false}"
if [ -f "/tmp/.wp-unhealthy" ]; then
echo "Error: WordPress health is compromised: $(cat "/tmp/.wp-unhealthy")"
return 1
fi
# If FULL_CHECK is not requested, site functionality check with curl is skipped
if [ "${FULL_CHECK}" = "false" ]; then
return 0
fi
curl -sSf --output "/dev/null" "http://localhost/"
return $?
}
main "${@}"
exit $?

View File

@@ -1,3 +1,3 @@
#!/usr/bin/env bash
/usr/local/bin/wp-cli --allow-root --path="/var/www/${WEB_ROOT}" "$@"
/usr/local/bin/wp-cli --allow-root --path="/var/www/html" "$@"

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -e
# Applies patch for preventing WordPress updates
function main() {
PATCH_FILE="${1:?PATCH_FILE is required}"
TARGET_FILE="${2:?TARGET_FILE is required}"
if [ ! -f "${PATCH_FILE}" ]; then
echo "> No such file [PATCH]: ${PATCH_FILE}"
return 1
fi
if [ ! -f "${TARGET_FILE}" ]; then
echo "> No such file [TARGET]: ${TARGET_FILE}"
return 1
fi
echo "> Loading patch ${PATCH_FILE}"
echo " Patching '${TARGET_FILE}'..."
patch --verbose "${TARGET_FILE}" <"${PATCH_FILE}"
MARK_READ_ONLY="${3:-true}"
if [ "${MARK_READ_ONLY}" = "true" ]; then
# This is done in order to prevent WordPress overwriting the file
echo " Marking the patched file read-only..."
chmod 0440 "${TARGET_FILE}"
fi
return 0
}
# Usage: main /etc/wp-mods/wp-admin-update-core.patch /var/www/html/wp-admin/update-core.php ?true|false
main "${@}"
exit $?

125
rootfs/usr/local/bin/wp-plugin Executable file
View File

@@ -0,0 +1,125 @@
#!/usr/bin/env bash
# Download plugin (curl)
# $1 - plugin slug
# $2 - plugin version (optional)
# Returns 0 on success, X on failure
download() {
PLUGIN_SLUG="${1:?download: PLUGIN_SLUG is required}"
PLUGIN_VERSION="${2:-}"
if [ -n "${PLUGIN_VERSION}" ]; then
PLUGIN_FILENAME="${PLUGIN_SLUG}.${PLUGIN_VERSION}.zip"
else
PLUGIN_FILENAME="${PLUGIN_SLUG}.zip"
fi
curl --fail -gsO "https://downloads.wordpress.org/plugin/${PLUGIN_FILENAME}" || return $?
echo "${PLUGIN_FILENAME}"
return 0
}
# Unpack plugin (unzip)
# $1 - plugin slug
# $2 - plugin version (optional)
# $3 - target directory (optional)
# Returns 0 on success, 1 on failure
unpack() {
TARGET_PLUGINS_DIR="${TARGET_PLUGINS_DIR:?check: TARGET_PLUGINS_DIR is required}"
PLUGIN_SLUG="${1:?unpack: PLUGIN_SLUG is required}"
PLUGIN_VERSION="${2:-}"
if [ -n "${PLUGIN_VERSION}" ]; then
PLUGIN_FILENAME="${PLUGIN_SLUG}.${PLUGIN_VERSION}.zip"
else
PLUGIN_FILENAME="${PLUGIN_SLUG}.zip"
fi
if [ -f "${PLUGIN_FILENAME}" ]; then
unzip -qq -d "${TARGET_PLUGINS_DIR}" "${PLUGIN_FILENAME}" || return $?
rm "${PLUGIN_FILENAME}" -f
return 0
fi
return 1
}
# Check if plugin is installed
# $1 - plugin slug
# Returns 0 if plugin is installed, 1 otherwise
check() {
TARGET_PLUGINS_DIR="${TARGET_PLUGINS_DIR:?check: TARGET_PLUGINS_DIR is required}"
PLUGIN_SLUG="${1:?check: PLUGIN_SLUG is required}"
PLUGIN_PATH="${TARGET_PLUGINS_DIR}/${PLUGIN_SLUG}"
# Check if plugin directory exists
if [ ! -d "${PLUGIN_PATH}" ]; then
return 1
fi
# Check if plugin file exists - if yes, plugin is probably installed successfully
if [ -f "${PLUGIN_PATH}/${PLUGIN_SLUG}.php" ]; then
return 0
fi
# Check if plugin directory is empty - if not, plugin is probably installed successfully
if [ "$(ls -A "${PLUGIN_PATH}")" ]; then
return 0
fi
# If we got here, then plugin is not installed
return 1
}
# Delete plugin
# $1 - plugin slug
# Returns 0 on success, X on failure
delete() {
TARGET_PLUGINS_DIR="${TARGET_PLUGINS_DIR:?delete: TARGET_PLUGINS_DIR is required}"
PLUGIN_SLUG="${1:?delete: PLUGIN_SLUG is required}"
PLUGIN_PATH="${TARGET_PLUGINS_DIR}/${PLUGIN_SLUG}"
# Check if plugin directory exists
if [ ! -d "${PLUGIN_PATH}" ]; then
return 1
fi
rm -rf "${PLUGIN_PATH}"
return $?
}
# Main function
main() {
COMMAND="${1:?COMMAND is required}"
TARGET_PLUGINS_DIR="${WP_PLUGINS_PATH:?WP_PLUGINS_PATH is required}"
export TARGET_PLUGINS_DIR
# Execute command by calling function with the same name
case "${COMMAND}" in
download)
download "${@:2}"
return $?
;;
unpack)
unpack "${@:2}"
return $?
;;
check)
check "${@:2}"
return $?
;;
delete)
delete "${@:2}"
return $?
;;
*)
echo "Error: Unknown command '${COMMAND}'"
return 1
;;
esac
}
main "${@}"
exit $?

130
rootfs/usr/local/bin/wp-theme Executable file
View File

@@ -0,0 +1,130 @@
#!/usr/bin/env bash
# Download theme (curl)
# $1 - theme slug
# $2 - theme version (optional)
# Returns 0 on success, X on failure
download() {
THEME_SLUG="${1:?download: THEME_SLUG is required}"
THEME_VERSION="${2:-}"
if [ -n "${THEME_VERSION}" ]; then
THEME_FILENAME="${THEME_SLUG}.${THEME_VERSION}.zip"
else
THEME_FILENAME="${THEME_SLUG}.zip"
fi
curl --fail -gsO "https://downloads.wordpress.org/theme/${THEME_FILENAME}" || return $?
echo "${THEME_FILENAME}"
return 0
}
# Unpack theme (unzip)
# $1 - theme slug
# $2 - theme version (optional)
# Returns 0 on success, 1 on failure
unpack() {
TARGET_THEMES_DIR="${TARGET_THEMES_DIR:?check: TARGET_THEMES_DIR is required}"
THEME_SLUG="${1:?unpack: THEME_SLUG is required}"
THEME_VERSION="${2:-}"
if [ -n "${THEME_VERSION}" ]; then
THEME_FILENAME="${THEME_SLUG}.${THEME_VERSION}.zip"
else
THEME_FILENAME="${THEME_SLUG}.zip"
fi
if [ -f "${THEME_FILENAME}" ]; then
unzip -qq -d "${TARGET_THEMES_DIR}" "${THEME_FILENAME}" || return $?
rm "${THEME_FILENAME}" -f
return 0
fi
return 1
}
# Check if theme is installed
# $1 - theme slug
# Returns 0 if theme is installed, 1 otherwise
check() {
TARGET_THEMES_DIR="${TARGET_THEMES_DIR:?check: TARGET_THEMES_DIR is required}"
THEME_SLUG="${1:?check: THEME_SLUG is required}"
THEME_PATH="${TARGET_THEMES_DIR}/${THEME_SLUG}"
# Check if theme directory exists
if [ ! -d "${THEME_PATH}" ]; then
return 1
fi
# Check if theme theme.json exists - if yes, theme is probably installed successfully
if [ -f "${THEME_PATH}/theme.json" ]; then
return 0
fi
# Check if theme index.php exists - if yes, theme is probably installed successfully
if [ -f "${THEME_PATH}/index.php" ]; then
return 0
fi
# Check if theme directory is empty - if not, theme is probably installed successfully
if [ "$(ls -A "${THEME_PATH}")" ]; then
return 0
fi
# If we got here, then theme is not installed
return 1
}
# Delete theme
# $1 - theme slug
# Returns 0 on success, X on failure
delete() {
TARGET_THEMES_DIR="${TARGET_THEMES_DIR:?delete: TARGET_THEMES_DIR is required}"
THEME_SLUG="${1:?delete: THEME_SLUG is required}"
THEME_PATH="${TARGET_THEMES_DIR}/${THEME_SLUG}"
# Check if theme directory exists
if [ ! -d "${THEME_PATH}" ]; then
return 1
fi
rm -rf "${THEME_PATH}"
return $?
}
# Main function
main() {
COMMAND="${1:?COMMAND is required}"
TARGET_THEMES_DIR="${WP_THEMES_PATH:?WP_THEMES_PATH is required}"
export TARGET_THEMES_DIR
# Execute command by calling function with the same name
case "${COMMAND}" in
download)
download "${@:2}"
return $?
;;
unpack)
unpack "${@:2}"
return $?
;;
check)
check "${@:2}"
return $?
;;
delete)
delete "${@:2}"
return $?
;;
*)
echo "Error: Unknown command '${COMMAND}'"
return 1
;;
esac
}
main "${@}"
exit $?

View File

@@ -0,0 +1,3 @@
<?php
echo 'Hello World!';

View File

@@ -1,113 +0,0 @@
<?php
/**
* The base configuration for WordPress
* Adapted for docker environment
* @author Aleksandar Puharic <xzero@elite7hackers.net>
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://codex.wordpress.org/Editing_wp-config.php
*
* @package WordPress
*/
/** Not needed behind the nginx-proxy */
define('FORCE_SSL_ADMIN', false);
define('FORCE_SSL_LOGIN', false);
/** Disable cron (will be run by system crond) */
define('DISABLE_WP_CRON', true);
/** Makes it easier to control in docker environment */
define('WP_CONTENT_DIR', $_ENV['WORDPRESS_CONTENT_DIR'] ?? (__DIR__ . '/wp-content'));
/**
* Redis Cache
*/
define('WP_REDIS_HOST', $_ENV['WORDPRESS_REDIS_HOST'] ?? null);
define('WP_CACHE', (bool)($_ENV['WORDPRESS_CACHE'] ?? false));
define('WP_CACHE_KEY_SALT', $_ENV['WORDPRESS_CACHE_KEY_SALT'] ?? null);
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', $_ENV['WORDPRESS_DB_NAME'] ?? 'wordpress');
/** MySQL database username */
define('DB_USER', $_ENV['WORDPRESS_DB_USER'] ?? 'wordpress');
/** MySQL database password */
define('DB_PASSWORD', $_ENV['WORDPRESS_DB_PASSWORD'] ?? '');
/** MySQL hostname */
define('DB_HOST', $_ENV['WORDPRESS_DB_HOST'] ?? 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', $_ENV['WORDPRESS_DB_CHARSET'] ?? 'utf8mb4');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', $_ENV['WORDPRESS_DB_COLLATION'] ?? '');
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', $_ENV['WORDPRESS_AUTH_KEY'] ?? '');
define('SECURE_AUTH_KEY', $_ENV['WORDPRESS_SECURE_AUTH_KEY'] ?? '');
define('LOGGED_IN_KEY', $_ENV['WORDPRESS_LOGGED_IN_KEY'] ?? '');
define('NONCE_KEY', $_ENV['WORDPRESS_NONCE_KEY'] ?? '');
define('AUTH_SALT', $_ENV['WORDPRESS_AUTH_SALT'] ?? '');
define('SECURE_AUTH_SALT', $_ENV['WORDPRESS_SECURE_AUTH_SALT'] ?? '');
define('LOGGED_IN_SALT', $_ENV['WORDPRESS_LOGGED_IN_SALT'] ?? '');
define('NONCE_SALT', $_ENV['WORDPRESS_NONCE_SALT'] ?? '');
/**#@-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = $_ENV['WORDPRESS_TABLE_PREFIX'] ?? 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define('WP_DEBUG', (bool)($_ENV['WORDPRESS_DEBUG'] ?? false));
/**
* Other settings
*/
define('FS_METHOD', 'direct');
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', __DIR__ . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');