diff --git a/Dockerfile b/Dockerfile index 8dc7828..7214273 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 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 FROM ghcr.io/n0rthernl1ghts/wordpress-unit-base:2.1.0 @@ -38,6 +42,7 @@ RUN apk add --update --no-cache patch COPY --from=rootfs ["/", "/"] RUN set -eux \ + && apk add --update --no-cache rsync \ && 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" diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-webuser-permissions/dependencies.d/init-wpcontent b/rootfs/etc/s6-overlay/s6-rc.d/init-webuser-permissions/dependencies.d/init-wpcontent new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/run b/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/run new file mode 100755 index 0000000..65e5958 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/run @@ -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 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/type b/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/type new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/up b/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/up new file mode 100644 index 0000000..8da8221 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/init-wpcontent/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-wpcontent/run \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-unitd/dependencies.d/init-wpcontent b/rootfs/etc/s6-overlay/s6-rc.d/svc-unitd/dependencies.d/init-wpcontent new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-wpcontent b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-wpcontent new file mode 100644 index 0000000..e69de29