mirror of
https://github.com/N0rthernL1ghts/wordpress.git
synced 2025-12-08 18:32:39 +01:00
Compare commits
72 Commits
other/depr
...
revert-15-
| Author | SHA1 | Date | |
|---|---|---|---|
| e96813bdd1 | |||
| f26a5d68e6 | |||
|
|
eed560bb99 | ||
|
5b75b4119e
|
|||
| 4d712f7861 | |||
| 83e0bc5924 | |||
|
04f0dc4d93
|
|||
|
ec520c2e42
|
|||
|
0a225eedd7
|
|||
|
9a2794d584
|
|||
|
e39555b0b1
|
|||
|
a6080cbef0
|
|||
|
7e55f47ac6
|
|||
|
f8beef6bf4
|
|||
|
cad36f6e7e
|
|||
|
a50ce69fc0
|
|||
|
6f165400a4
|
|||
|
f57537dfcf
|
|||
|
7c8fa6cfc8
|
|||
|
d236f0ba51
|
|||
|
69c43a5caa
|
|||
|
1357f2fec3
|
|||
|
fd6fba8dc9
|
|||
|
8a0671090e
|
|||
|
f70d3d891c
|
|||
|
fc85a1d8cb
|
|||
|
23192aaa94
|
|||
|
e184127d38
|
|||
|
aeb39d0f13
|
|||
|
250227f3e1
|
|||
|
90f38805fa
|
|||
|
ef47e1b2b9
|
|||
|
1b62dba10a
|
|||
|
f79da27583
|
|||
|
53ab34b35e
|
|||
|
47ba7873f1
|
|||
|
879df6c042
|
|||
|
8df891a400
|
|||
|
c26a0afd1f
|
|||
|
aa68d5ba82
|
|||
|
e2ed315ff2
|
|||
|
a8f2aadab2
|
|||
|
f387ec0773
|
|||
|
c41860611d
|
|||
|
4fc19fa5e7
|
|||
|
f81ec4c67e
|
|||
|
f0ce5dae9e
|
|||
| 924a9c9304 | |||
|
|
0b69603a10 | ||
|
2fd2e0d6aa
|
|||
| fcd9719d6b | |||
|
|
89fb3fa6a0 | ||
|
e398d3a71a
|
|||
|
64722d5b6c
|
|||
|
fedfaeafc4
|
|||
|
bb3f62ef10
|
|||
|
a72f393567
|
|||
|
705a2d505d
|
|||
|
dd43a2e929
|
|||
|
e5ad0997f6
|
|||
|
4edf0ee410
|
|||
|
fdb3c6727e
|
|||
|
824994c6b7
|
|||
|
3377076391
|
|||
|
88b4e4514a
|
|||
|
149e34bcd2
|
|||
|
0d454a15d9
|
|||
|
e344128779
|
|||
|
6d526d71e1
|
|||
|
550bcea00d
|
|||
|
68da285e90
|
|||
| a1563b89f4 |
14
.github/workflows/image.yml
vendored
14
.github/workflows/image.yml
vendored
@@ -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
|
||||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -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/
|
||||
|
||||
68
Dockerfile
68
Dockerfile
@@ -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
|
||||
|
||||
66
README.md
66
README.md
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
ARG PHP_VERSION=7.4
|
||||
ARG PHP_VERSION=8.1
|
||||
ARG WP_VERSION=6.0.2
|
||||
|
||||
|
||||
|
||||
14
patches/6.2.0/wp-admin-update-core.patch
Normal file
14
patches/6.2.0/wp-admin-update-core.patch
Normal 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.
|
||||
@@ -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 $?
|
||||
57
rootfs/etc/cont-init.d/10-verify-wordpress
Executable file
57
rootfs/etc/cont-init.d/10-verify-wordpress
Executable 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 $?
|
||||
@@ -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 $?
|
||||
117
rootfs/etc/cont-init.d/20-install-resources
Executable file
117
rootfs/etc/cont-init.d/20-install-resources
Executable 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 $?
|
||||
@@ -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;
|
||||
}
|
||||
21
rootfs/usr/local/bin/healthcheck
Executable file
21
rootfs/usr/local/bin/healthcheck
Executable 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 $?
|
||||
@@ -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" "$@"
|
||||
|
||||
36
rootfs/usr/local/bin/wp-apply-patch
Executable file
36
rootfs/usr/local/bin/wp-apply-patch
Executable 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
125
rootfs/usr/local/bin/wp-plugin
Executable 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
130
rootfs/usr/local/bin/wp-theme
Executable 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 $?
|
||||
3
rootfs/var/www/html/index.php
Normal file
3
rootfs/var/www/html/index.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
echo 'Hello World!';
|
||||
113
wp-config.php
113
wp-config.php
@@ -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');
|
||||
Reference in New Issue
Block a user