feat: add XML import on first container start

main
RadioParalelo 2026-03-05 00:12:31 +00:00
parent d33eccd2dc
commit 4257e7da36
8 changed files with 5484 additions and 27 deletions

7
.dockerignore 100644
View File

@ -0,0 +1,7 @@
db-data/
wp-data/
db-data/.my-healthcheck.cnf
.git
node_modules
*.log

View File

@ -1,36 +1,36 @@
# -------------------------------------------------
# 1️⃣ Base image official WordPress (PHP8.2 + Apache)
# 0️⃣ Base image official 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/*
# -------------------------------------------------
# 3️⃣ PHP configuration (optional increase limits)
# 2️⃣ PHP configuration (optional increase limits)
# -------------------------------------------------
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 && \
apt-get install -y --no-install-recommends unzip && \
apt-get install -y --no-install-recommends unzip mariadb-client && \
rm -rf /var/lib/apt/lists/* && \
curl -sS https://getcomposer.org/installer | \
php -- --install-dir=/usr/local/bin --filename=composer
# -------------------------------------------------
# 5⃣ Install WPCLI (handy for wp commands)
# 4⃣ WPCLI (already used by your old entrypoint)
# -------------------------------------------------
RUN 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
# -------------------------------------------------
# 6⃣ Install plugins via Composer
# 5⃣ Composerbased plugins
# -------------------------------------------------
WORKDIR /var/www/html
COPY composer.json composer.lock ./
@ -38,40 +38,39 @@ RUN composer install --no-dev --optimize-autoloader && \
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/
# -------------------------------------------------
# 8⃣ Copy the themes media folder into the theme directory
# -------------------------------------------------
COPY indy-wp/media/ /var/www/html/wp-content/uploads/2026/03/
# -------------------------------------------------
# 9⃣ Copy any muplugins (mustuse) **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 wpcontent 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 wpcontent
# -------------------------------------------------
RUN mkdir -p /var/www/html/wp-content/uploads && \
chown -R www-data:www-data /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 \
CMD curl -f http://localhost/wp-admin/install.php || exit 1
# -------------------------------------------------
# 📣 Expose HTTP
# -------------------------------------------------
EXPOSE 80
# -------------------------------------------------
# 🚀 Default command Apache in foreground
# 🚀 Use the wrapper, then the original entrypoint
# -------------------------------------------------
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["apache2-foreground"]

View File

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

View File

@ -1,7 +1,9 @@
#!/bin/bash
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
wp config create \
--dbname="${WORDPRESS_DB_NAME}" \
@ -12,5 +14,41 @@ if [ ! -f /var/www/html/wp-config.php ]; then
--allow-root
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, nonzero 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

9
functions.php 100644
View File

@ -0,0 +1,9 @@
<?php
// Remove parentthemes heavy assets you dont need
add_action( 'wp_enqueue_scripts', function () {
// Example: deregister a large font stylesheet the parent loads
wp_dequeue_style( 'indymedia-theme-fonts' );
// Example: deregister blockpattern script if it exists
wp_dequeue_script( 'indymedia-theme-patterns' );
}, 20 );

23
plugin-list.txt 100644
View File

@ -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

5
style.css 100644
View File

@ -0,0 +1,5 @@
/*
Theme Name: Indymedia WP
Template: indymedia-theme
Version: 0.1
*/