mirror of
https://github.com/N0rthernL1ghts/wordpress.git
synced 2024-11-23 10:51:10 +01:00
Add init-wpcontent script to fix error if wp-content is empty
This commit is contained in:
parent
108fd72c86
commit
6dba8a19f9
|
@ -29,6 +29,10 @@ COPY --from=wp-src ["/usr/src/wordpress/", "/var/www/html/"]
|
||||||
|
|
||||||
COPY ["patches/${WP_PATCH_VERSION}/wp-admin-update-core.patch", "/etc/wp-mods/"]
|
COPY ["patches/${WP_PATCH_VERSION}/wp-admin-update-core.patch", "/etc/wp-mods/"]
|
||||||
|
|
||||||
|
# Copy wp-content/themes to src - This is needed if wp-content is mounted as a volume and not initialized prior
|
||||||
|
COPY --from=wp-src ["/usr/src/wordpress/wp-content/themes/", "/usr/src/wordpress/wp-content/themes/"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Stage 3 - Final
|
# Stage 3 - Final
|
||||||
FROM ghcr.io/n0rthernl1ghts/wordpress-unit-base:2.1.0
|
FROM ghcr.io/n0rthernl1ghts/wordpress-unit-base:2.1.0
|
||||||
|
@ -38,6 +42,7 @@ RUN apk add --update --no-cache patch
|
||||||
COPY --from=rootfs ["/", "/"]
|
COPY --from=rootfs ["/", "/"]
|
||||||
|
|
||||||
RUN set -eux \
|
RUN set -eux \
|
||||||
|
&& apk add --update --no-cache rsync \
|
||||||
&& chmod a+x /usr/local/bin/wp \
|
&& chmod a+x /usr/local/bin/wp \
|
||||||
&& mv "/var/www/html/wp-config-docker.php" "/var/www/html/wp-config.php" \
|
&& 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"
|
&& wp-apply-patch "/etc/wp-mods/wp-admin-update-core.patch" "/var/www/html/wp-admin/update-core.php" "true"
|
||||||
|
|
24
rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/run
Executable file
24
rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/run
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/command/with-contenv bash
|
||||||
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
# init-wpcontent main
|
||||||
|
main() {
|
||||||
|
# This will prepend service name to all output from here
|
||||||
|
exec > >(while read -r line; do echo "[init-wpcontent] ${line}"; done) 2>&1
|
||||||
|
|
||||||
|
local wpContentDir="/var/www/html/wp-content"
|
||||||
|
local wpThemesDir="${wpContentDir}/themes"
|
||||||
|
|
||||||
|
# If themes directory is empty
|
||||||
|
if [ ! -d "${wpThemesDir}" ] || [ -z "$(ls -A "${wpThemesDir}")" ]; then
|
||||||
|
if [ "${WORDPRESS_INIT_NO_SYNC_THEMES:-false}" = "true" ]; then
|
||||||
|
echo "Warning: Themes directory is empty, but sync is disabled"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Themes directory is empty, copying default themes"
|
||||||
|
rsync -a --ignore-existing --progress /usr/src/wordpress/wp-content/themes "${wpContentDir}/"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
main
|
1
rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/type
Normal file
1
rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/type
Normal file
|
@ -0,0 +1 @@
|
||||||
|
oneshot
|
1
rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/up
Normal file
1
rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/up
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/etc/s6-overlay/s6-rc.d/init-wpcontent/run
|
Loading…
Reference in New Issue
Block a user