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
|
COPY config/php.ini /usr/local/etc/php/conf.d/custom.ini
|
||||||
|
|
||||||
# -------------------------------------------------
|
# ---- Install unzip & WP‑CLI --------------------------------------------
|
||||||
# 3️⃣ System utilities + Composer
|
|
||||||
# -------------------------------------------------
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends unzip && \
|
apt-get install -y --no-install-recommends unzip && \
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
curl -sS https://getcomposer.org/installer | \
|
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
||||||
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 && \
|
|
||||||
chmod +x wp-cli.phar && \
|
chmod +x wp-cli.phar && \
|
||||||
mv wp-cli.phar /usr/local/bin/wp
|
mv wp-cli.phar /usr/local/bin/wp
|
||||||
|
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
# -------------------------------------------------
|
# ---- WP‑CLI cache folder ------------------------------------------------
|
||||||
# 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
|
||||||
RUN mkdir -p /var/www/.wp-cli && chown -R www-data:www-data /var/www/.wp-cli
|
|
||||||
|
|
||||||
# -------------------------------------------------
|
# ---- Copy plugins from builder -----------------------------------------
|
||||||
# 5️⃣ (Removed) theme‑install step that caused the error
|
COPY --from=builder \
|
||||||
# -------------------------------------------------
|
--chown=www-data:www-data \
|
||||||
|
/app/wp-content/plugins /var/www/html/wp-content/plugins
|
||||||
|
|
||||||
# -------------------------------------------------
|
# ---- Copy the theme ------------------------------------------------------
|
||||||
# 6️⃣ Writable uploads folder
|
COPY --from=theme-preparer \
|
||||||
# -------------------------------------------------
|
--chown=www-data:www-data \
|
||||||
RUN mkdir -p wp-content/uploads && \
|
/tmp/indy-wp-theme* /var/www/html/wp-content/themes/indy-wp-theme
|
||||||
chown -R www-data:www-data wp-content && \
|
|
||||||
chmod -R 775 wp-content
|
|
||||||
|
|
||||||
# -------------------------------------------------
|
# ---- Permissions ---------------------------------------------------------
|
||||||
# 7️⃣ Composer‑based plugins (same as before)
|
USER www-data
|
||||||
# -------------------------------------------------
|
RUN mkdir -p /var/www/html/wp-content/uploads && \
|
||||||
COPY composer.json composer.lock ./
|
chmod -R 755 /var/www/html/wp-content/plugins && \
|
||||||
RUN composer install --no-dev --optimize-autoloader && \
|
chmod -R 755 /var/www/html/wp-content/themes && \
|
||||||
rm composer.json composer.lock && \
|
chmod -R 775 /var/www/html/wp-content/uploads
|
||||||
chown -R www-data:www-data wp-content/plugins && \
|
|
||||||
chmod -R 755 wp-content/plugins
|
|
||||||
|
|
||||||
# -------------------------------------------------
|
# ---- Healthcheck ---------------------------------------------------------
|
||||||
# 8️⃣ Healthcheck
|
|
||||||
# -------------------------------------------------
|
|
||||||
HEALTHCHECK --interval=30s --timeout=5s \
|
HEALTHCHECK --interval=30s --timeout=5s \
|
||||||
CMD curl -f http://localhost/wp-admin/ || exit 1
|
CMD curl -f http://localhost/wp-admin/ || exit 1
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# -------------------------------------------------
|
# ---- Custom entrypoint scripts -------------------------------------------
|
||||||
# 📜 Custom entrypoint (calls official one first)
|
|
||||||
# -------------------------------------------------
|
|
||||||
COPY entrypoint.sh /usr/local/bin/
|
COPY entrypoint.sh /usr/local/bin/
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
|
||||||
|
|
||||||
COPY entrypoint-theme.sh /usr/local/bin/
|
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"]
|
CMD ["apache2-foreground"]
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,13 @@ services:
|
||||||
WORDPRESS_DB_PASSWORD: wp_pass
|
WORDPRESS_DB_PASSWORD: wp_pass
|
||||||
WORDPRESS_DB_NAME: wp_db
|
WORDPRESS_DB_NAME: wp_db
|
||||||
volumes:
|
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
|
- ./config/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro
|
||||||
- ./theme/images:/var/www/html/wp-content/uploads/theme-images:ro
|
- ./theme/images:/var/www/html/wp-content/uploads/theme-images:ro
|
||||||
# entrypoint: ["/usr/local/bin/entrypoint-theme.sh"]
|
depends_on:
|
||||||
|
- db
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: mariadb:10.11
|
image: mariadb:10.11
|
||||||
container_name: imc_db
|
container_name: imc_db
|
||||||
|
|
@ -27,3 +30,5 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./db-data:/var/lib/mysql
|
- ./db-data:/var/lib/mysql
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
uploads:
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
image: wordpress:latest
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/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
|
while [ ! -f /var/www/html/wp-config.php ]; do
|
||||||
echo "⏳ Waiting for WordPress core to be ready..."
|
echo "⏳ Waiting for WordPress core to be ready..."
|
||||||
|
|
@ -10,34 +10,31 @@ while [ ! -f /var/www/html/wp-config.php ]; do
|
||||||
done
|
done
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# Download & install the custom theme
|
# Ensure theme directory ownership & permissions
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
THEME_ZIP="https://codeberg.org/radioparalelo/indy-wp-theme/archive/main.zip"
|
chown -R www-data:www-data /var/www/html/wp-content/themes
|
||||||
TMP_DIR=$(mktemp -d)
|
chmod -R 755 /var/www/html/wp-content/themes
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# Activate the theme (force)
|
# Activate the theme that is already present
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
su www-data -s /bin/bash -c "\
|
THEME_SLUG="indy-wp-theme"
|
||||||
wp theme activate indywp \
|
|
||||||
|
# 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 \
|
--allow-root \
|
||||||
--path=/var/www/html \
|
--path=/var/www/html
|
||||||
"
|
fi
|
||||||
|
|
||||||
# -------------------------------------------------
|
|
||||||
# Hand over to the official entrypoint (starts Apache)
|
|
||||||
# -------------------------------------------------
|
|
||||||
exec /usr/local/bin/docker-entrypoint.sh "$@"
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
#!/bin/bash
|
#!/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
|
if [ ! -d /var/www/html/wp-admin ]; then
|
||||||
echo "❌ WordPress core missing after docker-entrypoint.sh"
|
echo "❌ WordPress core missing after docker-entrypoint.sh"
|
||||||
|
|
@ -15,12 +16,14 @@ if [ ! -d /var/www/html/wp-admin ]; then
|
||||||
fi
|
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
|
until wp db check --path=/var/www/html --allow-root > /dev/null 2>&1; do
|
||||||
echo "⏳ Waiting for database..."
|
echo "⏳ Waiting for database..."
|
||||||
|
|
@ -28,6 +31,13 @@ until wp db check --path=/var/www/html --allow-root > /dev/null 2>&1; do
|
||||||
done
|
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 "$@"
|
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 |