feat: add XML import on first container start
parent
d33eccd2dc
commit
4257e7da36
|
|
@ -0,0 +1,7 @@
|
||||||
|
db-data/
|
||||||
|
wp-data/
|
||||||
|
|
||||||
|
db-data/.my-healthcheck.cnf
|
||||||
|
.git
|
||||||
|
node_modules
|
||||||
|
*.log
|
||||||
47
Dockerfile
47
Dockerfile
|
|
@ -1,36 +1,36 @@
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 1️⃣ Base image – official WordPress (PHP 8.2 + Apache)
|
# 0️⃣ Base image – official WordPress (PHP 8.2 + Apache)
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
FROM wordpress:php8.2-apache
|
FROM wordpress:php8.2-apache
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 2️⃣ Remove every bundled WordPress theme (bloat)
|
# 1️⃣ Remove bundled themes (optional)
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
RUN rm -rf /usr/src/wordpress/wp-content/themes/*
|
RUN rm -rf /usr/src/wordpress/wp-content/themes/*
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 3️⃣ PHP configuration (optional – increase limits)
|
# 2️⃣ PHP configuration (optional – increase limits)
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
COPY config/php.ini /usr/local/etc/php/conf.d/custom.ini
|
COPY config/php.ini /usr/local/etc/php/conf.d/custom.ini
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 4️⃣ Install system utilities (unzip) and Composer
|
# 3️⃣ System utilities + mariadb client (for DB check)
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends unzip && \
|
apt-get install -y --no-install-recommends unzip mariadb-client && \
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
curl -sS https://getcomposer.org/installer | \
|
curl -sS https://getcomposer.org/installer | \
|
||||||
php -- --install-dir=/usr/local/bin --filename=composer
|
php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 5️⃣ Install WP‑CLI (handy for wp commands)
|
# 4️⃣ WP‑CLI (already used by your old entrypoint)
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
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
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 6️⃣ Install plugins via Composer
|
# 5️⃣ Composer‑based plugins
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
COPY composer.json composer.lock ./
|
COPY composer.json composer.lock ./
|
||||||
|
|
@ -38,40 +38,39 @@ RUN composer install --no-dev --optimize-autoloader && \
|
||||||
rm composer.json composer.lock
|
rm composer.json composer.lock
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 7️⃣ Copy your custom theme (already built)
|
# 6️⃣ Theme & media (your existing copies)
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
COPY indy-wp/indywp/ /var/www/html/wp-content/themes/indywp/
|
COPY indy-wp/indywp/ /var/www/html/wp-content/themes/indywp/
|
||||||
|
|
||||||
# -------------------------------------------------
|
|
||||||
# 8️⃣ Copy the theme’s media folder into the theme directory
|
|
||||||
# -------------------------------------------------
|
|
||||||
COPY indy-wp/media/ /var/www/html/wp-content/uploads/2026/03/
|
COPY indy-wp/media/ /var/www/html/wp-content/uploads/2026/03/
|
||||||
# -------------------------------------------------
|
|
||||||
# 9️⃣ Copy any mu‑plugins (must‑use) – **default folder**
|
|
||||||
# -------------------------------------------------
|
|
||||||
# Anything placed in the local `mu-plugins/` directory will be
|
|
||||||
# loaded automatically by WordPress on every request.
|
|
||||||
#COPY mu-plugins/ /var/www/html/wp-content/mu-plugins/
|
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 🔟 Ensure wp‑content is writable by www-data
|
# 7️⃣ Export file – the XML you exported from WP
|
||||||
|
# -------------------------------------------------
|
||||||
|
COPY export/indymedia.WordPress.xml /tmp/site-export.xml
|
||||||
|
|
||||||
|
# -------------------------------------------------
|
||||||
|
# 8️⃣ Permissions for wp‑content
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
RUN mkdir -p /var/www/html/wp-content/uploads && \
|
RUN mkdir -p /var/www/html/wp-content/uploads && \
|
||||||
chown -R www-data:www-data /var/www/html/wp-content && \
|
chown -R www-data:www-data /var/www/html/wp-content && \
|
||||||
chmod -R 775 /var/www/html/wp-content
|
chmod -R 775 /var/www/html/wp-content
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 🛡️ Healthcheck (optional)
|
# 9️⃣ Custom entrypoint (wrapper)
|
||||||
|
# -------------------------------------------------
|
||||||
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
# -------------------------------------------------
|
||||||
|
# 🔟 Healthcheck (optional)
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
HEALTHCHECK --interval=30s --timeout=5s \
|
HEALTHCHECK --interval=30s --timeout=5s \
|
||||||
CMD curl -f http://localhost/wp-admin/install.php || exit 1
|
CMD curl -f http://localhost/wp-admin/install.php || exit 1
|
||||||
|
|
||||||
# -------------------------------------------------
|
|
||||||
# 📣 Expose HTTP
|
|
||||||
# -------------------------------------------------
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# 🚀 Default command – Apache in foreground
|
# 🚀 Use the wrapper, then the original entrypoint
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
CMD ["apache2-foreground"]
|
CMD ["apache2-foreground"]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
image: wordpress:latest
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# If the config file does not exist, generate it from the env vars
|
# -----------------------------------------------------------------
|
||||||
|
# 1️⃣ Generate wp-config.php if it does not exist (your original logic)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
if [ ! -f /var/www/html/wp-config.php ]; then
|
if [ ! -f /var/www/html/wp-config.php ]; then
|
||||||
wp config create \
|
wp config create \
|
||||||
--dbname="${WORDPRESS_DB_NAME}" \
|
--dbname="${WORDPRESS_DB_NAME}" \
|
||||||
|
|
@ -12,5 +14,41 @@ if [ ! -f /var/www/html/wp-config.php ]; then
|
||||||
--allow-root
|
--allow-root
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Hand over to the official WordPress entrypoint
|
# -----------------------------------------------------------------
|
||||||
exec docker-entrypoint.sh "$@"
|
# 2️⃣ Helper: does the DB already have WordPress tables?
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
db_is_empty() {
|
||||||
|
# `wp db check` returns 0 when tables exist, non‑zero otherwise
|
||||||
|
wp db check > /dev/null 2>&1
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# 3️⃣ If the DB is empty, perform a fresh install and import the XML
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
if ! db_is_empty; then
|
||||||
|
echo "⚡ Database empty – installing WordPress and importing XML …"
|
||||||
|
|
||||||
|
# Core install (adjust URL, title, admin credentials as needed)
|
||||||
|
wp core install \
|
||||||
|
--url="http://localhost" \
|
||||||
|
--title="IndyMedia" \
|
||||||
|
--admin_user=admin \
|
||||||
|
--admin_password=admin123 \
|
||||||
|
--admin_email=admin@example.com \
|
||||||
|
--skip-email \
|
||||||
|
--allow-root
|
||||||
|
|
||||||
|
# Import the exported content
|
||||||
|
wp import /tmp/site-export.xml --authors=create --skip=image_resize --allow-root
|
||||||
|
|
||||||
|
# Flush rewrite rules so permalinks work
|
||||||
|
wp rewrite flush --hard --allow-root
|
||||||
|
|
||||||
|
echo "✅ Import complete."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# 4️⃣ Hand over to the official WordPress entrypoint (starts Apache)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
exec /usr/local/bin/docker-entrypoint.sh "$@"
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
// Remove parent‑theme’s heavy assets you don’t need
|
||||||
|
add_action( 'wp_enqueue_scripts', function () {
|
||||||
|
// Example: deregister a large font stylesheet the parent loads
|
||||||
|
wp_dequeue_style( 'indymedia-theme-fonts' );
|
||||||
|
|
||||||
|
// Example: deregister block‑pattern script if it exists
|
||||||
|
wp_dequeue_script( 'indymedia-theme-patterns' );
|
||||||
|
}, 20 );
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
activitypub
|
||||||
|
antispam-bee
|
||||||
|
automatic-featured-images-from-youtube-vimeo
|
||||||
|
classic-editor
|
||||||
|
easyfonts
|
||||||
|
embed-privacy
|
||||||
|
exif-remover
|
||||||
|
frontend-post-submission-manager
|
||||||
|
indie-web
|
||||||
|
lh-wayback-machine
|
||||||
|
loginpress
|
||||||
|
og
|
||||||
|
pretty-rss-feeds
|
||||||
|
redirection
|
||||||
|
remove-ip
|
||||||
|
rss-featured-image
|
||||||
|
safe-paste
|
||||||
|
syndication-links
|
||||||
|
unpredictable-image-filenames
|
||||||
|
webmention
|
||||||
|
wp-super-cache
|
||||||
|
xo-featured-image-tools
|
||||||
|
zapier-for-wordpress
|
||||||
Loading…
Reference in New Issue