stable update – Dockerfile, entrypoint, theme handling, etc.

main
radioparalelo 2026-03-10 22:07:14 +00:00
parent 9f8f5e73eb
commit 41cd7b91c4
13 changed files with 4064 additions and 90 deletions

View File

@ -1,74 +1,88 @@
FROM wordpress:php8.2-apache AS base
# -------------------------------------------------
# Stage 1 build Composerbased plugins
# -------------------------------------------------
FROM php:8.2-cli AS builder
RUN apt-get update && \
apt-get install -y --no-install-recommends unzip git && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY composer.json composer.lock ./
RUN curl -sS https://getcomposer.org/installer | php && \
php composer.phar install --no-dev --optimize-autoloader && \
rm -f composer.json composer.lock
# -------------------------------------------------
# 1⃣ Remove bundled themes (keep only core)
# Stage 2 prepare the Indy WP theme (tar.gz version)
# -------------------------------------------------
RUN rm -rf /usr/src/wordpress/wp-content/themes/*
FROM php:8.2-apache AS theme-preparer
RUN apt-get update && \
apt-get install -y --no-install-recommends wget tar && \
rm -rf /var/lib/apt/lists/*
ARG THEME_TAG=v1.0.0
# expose the tag to the runtime (used by the entrypoint)
ENV THEME_TAG=${THEME_TAG}
ARG TAR_URL=https://codeberg.org/radioparalelo/indy-wp-theme/archive/${THEME_TAG}.tar.gz
RUN wget -O /tmp/indy-wp-theme.tar.gz "${TAR_URL}" && \
tar -xzf /tmp/indy-wp-theme.tar.gz -C /tmp && \
rm /tmp/indy-wp-theme.tar.gz
# -------------------------------------------------
# 2⃣ Custom PHP config
# Stage 3 final WordPress image
# -------------------------------------------------
FROM wordpress:php8.2-apache
# ---- Custom PHP config -------------------------------------------------
COPY config/php.ini /usr/local/etc/php/conf.d/custom.ini
# -------------------------------------------------
# 3⃣ System utilities + Composer
# -------------------------------------------------
# ---- Install unzip & WPCLI --------------------------------------------
RUN apt-get update && \
apt-get install -y --no-install-recommends unzip && \
rm -rf /var/lib/apt/lists/* && \
curl -sS https://getcomposer.org/installer | \
php -- --install-dir=/usr/local/bin --filename=composer
# -------------------------------------------------
# 4⃣ WPCLI
# -------------------------------------------------
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
chmod +x wp-cli.phar && \
mv wp-cli.phar /usr/local/bin/wp
WORKDIR /var/www/html
# -------------------------------------------------
# Give www-data ownership of WPCLI cache folder
# -------------------------------------------------
RUN mkdir -p /var/www/.wp-cli && chown -R www-data:www-data /var/www/.wp-cli
# ---- WPCLI cache folder ------------------------------------------------
RUN mkdir -p /var/www/.wp-cli && \
chown -R www-data:www-data /var/www/.wp-cli
# -------------------------------------------------
# 5⃣ (Removed) themeinstall step that caused the error
# -------------------------------------------------
# ---- Copy plugins from builder -----------------------------------------
COPY --from=builder \
--chown=www-data:www-data \
/app/wp-content/plugins /var/www/html/wp-content/plugins
# -------------------------------------------------
# 6⃣ Writable uploads folder
# -------------------------------------------------
RUN mkdir -p wp-content/uploads && \
chown -R www-data:www-data wp-content && \
chmod -R 775 wp-content
# ---- Copy the theme ------------------------------------------------------
COPY --from=theme-preparer \
--chown=www-data:www-data \
/tmp/indy-wp-theme* /var/www/html/wp-content/themes/indy-wp-theme
# -------------------------------------------------
# 7⃣ Composerbased plugins (same as before)
# -------------------------------------------------
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader && \
rm composer.json composer.lock && \
chown -R www-data:www-data wp-content/plugins && \
chmod -R 755 wp-content/plugins
# ---- Permissions ---------------------------------------------------------
USER www-data
RUN mkdir -p /var/www/html/wp-content/uploads && \
chmod -R 755 /var/www/html/wp-content/plugins && \
chmod -R 755 /var/www/html/wp-content/themes && \
chmod -R 775 /var/www/html/wp-content/uploads
# -------------------------------------------------
# 8⃣ Healthcheck
# -------------------------------------------------
# ---- Healthcheck ---------------------------------------------------------
HEALTHCHECK --interval=30s --timeout=5s \
CMD curl -f http://localhost/wp-admin/ || exit 1
EXPOSE 80
# -------------------------------------------------
# 📜 Custom entrypoint (calls official one first)
# -------------------------------------------------
# ---- Custom entrypoint scripts -------------------------------------------
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
COPY entrypoint-theme.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint-theme.sh
USER root
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/entrypoint-theme.sh
USER www-data
ENTRYPOINT ["entrypoint.sh"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["apache2-foreground"]

View File

@ -11,10 +11,13 @@ services:
WORDPRESS_DB_PASSWORD: wp_pass
WORDPRESS_DB_NAME: wp_db
volumes:
- ./wp-data/uploads:/var/www/html/wp-content/uploads
# Persist only the uploads folder never overwrite the core
- uploads:/var/www/html/wp-content/uploads
- ./config/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro
- ./theme/images:/var/www/html/wp-content/uploads/theme-images:ro
# entrypoint: ["/usr/local/bin/entrypoint-theme.sh"]
depends_on:
- db
db:
image: mariadb:10.11
container_name: imc_db
@ -27,3 +30,5 @@ services:
volumes:
- ./db-data:/var/lib/mysql
volumes:
uploads:

View File

@ -1 +0,0 @@
image: wordpress:latest

View File

@ -1,43 +1,40 @@
#!/usr/bin/env bash
set -e
set -euo pipefail
# -------------------------------------------------
# Wait until WordPress core (wp-config.php) exists
# Wait for wp-config.php (core ready)
# -------------------------------------------------
while [ ! -f /var/www/html/wp-config.php ]; do
echo "⏳ Waiting for WordPress core to be ready..."
sleep 2
echo "⏳ Waiting for WordPress core to be ready..."
sleep 2
done
# -------------------------------------------------
# Download & install the custom theme
# Ensure theme directory ownership & permissions
# -------------------------------------------------
THEME_ZIP="https://codeberg.org/radioparalelo/indy-wp-theme/archive/main.zip"
TMP_DIR=$(mktemp -d)
echo "🚀 Downloading IndyWP theme archive..."
curl -L "$THEME_ZIP" -o "$TMP_DIR/main.zip"
echo "🔧 Extracting archive..."
unzip -q "$TMP_DIR/main.zip" -d "$TMP_DIR"
EXTRACTED=$(find "$TMP_DIR" -maxdepth 1 -type d -name "indy-wp-theme*" | head -n1)
TARGET="/var/www/html/wp-content/themes/indywp"
rm -rf "$TARGET"
mv "$EXTRACTED" "$TARGET"
rm -rf "$TMP_DIR"
chown -R www-data:www-data /var/www/html/wp-content/themes
chmod -R 755 /var/www/html/wp-content/themes
# -------------------------------------------------
# Activate the theme (force)
# Activate the theme that is already present
# -------------------------------------------------
su www-data -s /bin/bash -c "\
wp theme activate indywp \
--allow-root \
--path=/var/www/html \
"
THEME_SLUG="indy-wp-theme"
# -------------------------------------------------
# Hand over to the official entrypoint (starts Apache)
# -------------------------------------------------
exec /usr/local/bin/docker-entrypoint.sh "$@"
# If the theme folder is missing (e.g., a volume was mounted over it),
# fall back to the tarball that matches the buildtime tag.
if [ ! -d "/var/www/html/wp-content/themes/${THEME_SLUG}" ]; then
echo "⚠️ Theme folder missing extracting the builtin ${THEME_TAG} archive …"
# The archive was already extracted during the build, but if a volume
# overwrote the directory we can reextract it from the images copy:
tar -xzf "/tmp/indy-wp-theme.tar.gz" -C "/var/www/html/wp-content/themes"
chown -R www-data:www-data "/var/www/html/wp-content/themes/${THEME_SLUG}"
chmod -R 755 "/var/www/html/wp-content/themes/${THEME_SLUG}"
fi
# Activate if not already active
if ! wp theme is-active "$THEME_SLUG" --allow-root --path=/var/www/html; then
echo "🚀 Activating IndyWP theme (${THEME_TAG}) …"
wp theme activate "$THEME_SLUG" \
--allow-root \
--path=/var/www/html
fi

View File

@ -1,33 +1,43 @@
#!/bin/bash
set -eu
set -euo pipefail # fail fast, treat unset vars as errors, propagate pipe failures
# -------------------------------------------------
# 0Run the official WordPress entrypoint first
# 0Source the official WordPress entrypoint
# -------------------------------------------------
docker-entrypoint.sh "$@"
# This runs the WordPress init *without* starting Apache.
. /usr/local/bin/docker-entrypoint.sh
# -------------------------------------------------
# 1⃣ Verify core exists (optional safety net)
# 1⃣ Verify core exists (safety net)
# -------------------------------------------------
if [ ! -d /var/www/html/wp-admin ]; then
echo "❌ WordPress core missing after docker-entrypoint.sh"
exit 1
echo "❌ WordPress core missing after docker-entrypoint.sh"
exit 1
fi
# -------------------------------------------------
# 2wp-config.php (already created by the official entrypoint)
# 2Ensure uploads folder is present & writable
# -------------------------------------------------
# No need to create it here the official entrypoint does it.
mkdir -p /var/www/html/wp-content/uploads
chmod 775 /var/www/html/wp-content/uploads
chown -R www-data:www-data /var/www/html/wp-content/uploads
# -------------------------------------------------
# 3⃣ Wait for DB to be ready (optional, the official entrypoint also does this)
# 3⃣ Wait for DB to be ready (optional but cheap)
# -------------------------------------------------
until wp db check --path=/var/www/html --allow-root > /dev/null 2>&1; do
echo "⏳ Waiting for database..."
sleep 2
echo "⏳ Waiting for database..."
sleep 2
done
# -------------------------------------------------
# 4⃣ Hand over to the themeinstaller (entrypoint-theme.sh will be called later)
# 4⃣ Run the theme installer (once)
# -------------------------------------------------
if ! wp theme is-installed indy-wp-theme --allow-root --path=/var/www/html; then
/usr/local/bin/entrypoint-theme.sh
fi
# -------------------------------------------------
# 5⃣ Hand control back to the official entrypoint (starts Apache)
# -------------------------------------------------
exec /usr/local/bin/docker-entrypoint.sh "$@"

3949
project-structure.txt 100644

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB