stable update – Dockerfile, entrypoint, theme handling, etc.
104
Dockerfile
|
|
@ -1,74 +1,88 @@
|
|||
FROM wordpress:php8.2-apache AS base
|
||||
# -------------------------------------------------
|
||||
# Stage 1 – build Composer‑based 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 & WP‑CLI --------------------------------------------
|
||||
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️⃣ WP‑CLI
|
||||
# -------------------------------------------------
|
||||
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 WP‑CLI cache folder
|
||||
# -------------------------------------------------
|
||||
RUN mkdir -p /var/www/.wp-cli && chown -R www-data:www-data /var/www/.wp-cli
|
||||
# ---- WP‑CLI cache folder ------------------------------------------------
|
||||
RUN mkdir -p /var/www/.wp-cli && \
|
||||
chown -R www-data:www-data /var/www/.wp-cli
|
||||
|
||||
# -------------------------------------------------
|
||||
# 5️⃣ (Removed) theme‑install 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️⃣ Composer‑based 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"]
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
image: wordpress:latest
|
||||
|
|
@ -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 Indy‑WP 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 build‑time tag.
|
||||
if [ ! -d "/var/www/html/wp-content/themes/${THEME_SLUG}" ]; then
|
||||
echo "⚠️ Theme folder missing – extracting the built‑in ${THEME_TAG} archive …"
|
||||
# The archive was already extracted during the build, but if a volume
|
||||
# overwrote the directory we can re‑extract it from the image’s 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 Indy‑WP theme (${THEME_TAG}) …"
|
||||
wp theme activate "$THEME_SLUG" \
|
||||
--allow-root \
|
||||
--path=/var/www/html
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,33 +1,43 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
set -euo pipefail # fail fast, treat unset vars as errors, propagate pipe failures
|
||||
|
||||
# -------------------------------------------------
|
||||
# 0️⃣ Run the official WordPress entrypoint first
|
||||
# 0️⃣ Source 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
|
||||
|
||||
# -------------------------------------------------
|
||||
# 2️⃣ wp-config.php (already created by the official entrypoint)
|
||||
# 2️⃣ Ensure 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 theme‑installer (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 "$@"
|
||||
|
|
|
|||
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |