diff --git a/Dockerfile b/Dockerfile index 7208e3c..73c2842 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ RUN composer install --no-dev --optimize-autoloader && \ # 8️⃣ Healthcheck # ------------------------------------------------- HEALTHCHECK --interval=30s --timeout=5s \ - CMD curl -f http://localhost/wp-admin/install.php || exit 1 + CMD curl -f http://localhost/wp-admin/ || exit 1 EXPOSE 80 diff --git a/docker-compose.yml b/docker-compose.yml index 4c4b43a..44e9376 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: - ./wp-data/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"] +# entrypoint: ["/usr/local/bin/entrypoint-theme.sh"] db: image: mariadb:10.11 container_name: imc_db diff --git a/entrypoint-theme.sh b/entrypoint-theme.sh index ce7aac1..79e7a19 100644 --- a/entrypoint-theme.sh +++ b/entrypoint-theme.sh @@ -2,7 +2,7 @@ set -e # ------------------------------------------------- -# Wait until WordPress core (wp‑config.php) exists +# Wait until WordPress core (wp-config.php) exists # ------------------------------------------------- while [ ! -f /var/www/html/wp-config.php ]; do echo "⏳ Waiting for WordPress core to be ready..." @@ -10,30 +10,22 @@ while [ ! -f /var/www/html/wp-config.php ]; do done # ------------------------------------------------- -# Theme source – Codeberg archive (bare repo) +# Download & install the custom theme # ------------------------------------------------- THEME_ZIP="https://codeberg.org/radioparalelo/indy-wp-theme/archive/main.zip" TMP_DIR=$(mktemp -d) -# ------------------------------------------------- -# Download + unzip → ensure the folder is named `indywp` -# ------------------------------------------------- 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" -# The extracted folder will be something like `indy-wp-theme-main/` EXTRACTED=$(find "$TMP_DIR" -maxdepth 1 -type d -name "indy-wp-theme*" | head -n1) - -# Move/rename it to the slug WordPress expects (`indywp`) TARGET="/var/www/html/wp-content/themes/indywp" -echo "📁 Installing theme to $TARGET ..." -rm -rf "$TARGET" # remove any previous copy -mv "$EXTRACTED" "$TARGET" -# Clean up temporary files +rm -rf "$TARGET" +mv "$EXTRACTED" "$TARGET" rm -rf "$TMP_DIR" # ------------------------------------------------- @@ -46,6 +38,6 @@ su www-data -s /bin/bash -c "\ " # ------------------------------------------------- -# Start Apache (Docker’s default entrypoint) +# Hand over to the official entrypoint (starts Apache) # ------------------------------------------------- -exec docker-entrypoint.sh apache2-foreground \ No newline at end of file +exec /usr/local/bin/docker-entrypoint.sh "$@" diff --git a/entrypoint.sh b/entrypoint.sh index 1a4a085..5b04585 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,12 +2,12 @@ set -eu # ------------------------------------------------- -# 0️⃣ Run the official WordPress entrypoint first +# 0️⃣ Run the official WordPress entrypoint first # ------------------------------------------------- docker-entrypoint.sh "$@" # ------------------------------------------------- -# 1️⃣ Verify core exists +# 1️⃣ Verify core exists (optional safety net) # ------------------------------------------------- if [ ! -d /var/www/html/wp-admin ]; then echo "❌ WordPress core missing after docker-entrypoint.sh" @@ -15,24 +15,12 @@ if [ ! -d /var/www/html/wp-admin ]; then fi # ------------------------------------------------- -# 2️⃣ wp-config.php +# 2️⃣ wp-config.php (already created by the official entrypoint) # ------------------------------------------------- -if [ ! -f /var/www/html/wp-config.php ]; then - echo "⚙️ Creating wp-config.php..." - wp config create \ - --dbname="${WORDPRESS_DB_NAME}" \ - --dbuser="${WORDPRESS_DB_USER}" \ - --dbpass="${WORDPRESS_DB_PASSWORD}" \ - --dbhost="${WORDPRESS_DB_HOST}" \ - --path=/var/www/html \ - --allow-root -fi - -sed -i '/^?>/d' /var/www/html/wp-config.php -echo "define('FS_METHOD','direct');" >> /var/www/html/wp-config.php +# No need to create it here – the official entrypoint does it. # ------------------------------------------------- -# 3️⃣ Wait for DB to be ready +# 3️⃣ Wait for DB to be ready (optional, the official entrypoint also does this) # ------------------------------------------------- until wp db check --path=/var/www/html --allow-root > /dev/null 2>&1; do echo "⏳ Waiting for database..." @@ -40,30 +28,6 @@ until wp db check --path=/var/www/html --allow-root > /dev/null 2>&1; do done # ------------------------------------------------- -# 4️⃣ Install core if not already installed -# ------------------------------------------------- -if ! wp core is-installed --path=/var/www/html --allow-root; then - echo "🚀 Installing WordPress core..." - wp core install \ - --url="http://localhost" \ - --title="IndyMedia" \ - --admin_user=admin \ - --admin_password=admin123 \ - --admin_email=admin@example.com \ - --skip-email \ - --allow-root -fi - -# ------------------------------------------------- -# 5️⃣ Activate our custom theme (force) -# ------------------------------------------------- -if wp theme is-installed indywp --allow-root; then - wp theme activate indywp --allow-root -else - echo "⚠️ indywp theme not found – check Dockerfile copy step." -fi - -# ------------------------------------------------- -# 6️⃣ Hand over to the official entrypoint (starts Apache) +# 4️⃣ Hand over to the theme‑installer (entrypoint-theme.sh will be called later) # ------------------------------------------------- exec /usr/local/bin/docker-entrypoint.sh "$@"