CompleteNoobs Docker Image 2

From CompleteNoobs
Revision as of 14:46, 2 September 2025 by AwesomO (talk | contribs) (5.2: Test Extensions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Please Select a Licence from the LICENCE_HEADERS page
And place at top of your page
If no Licence is Selected/Appended, Default will be CC0

Default Licence IF there is no Licence placed below this notice! When you edit this page, you agree to release your contribution under the CC0 Licence

LICENCE: More information about the cc0 licence can be found here:
https://creativecommons.org/share-your-work/public-domain/cc0

The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.

You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Licence:

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.

For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following:

   the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
   moral rights retained by the original author(s) and/or performer(s);
   publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;
   rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below;
   rights protecting the extraction, dissemination, use and reuse of data in a Work;
   database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
   other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose.

4. Limitations and Disclaimers.

   No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
   Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
   Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
   Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.

todo

  • Use Dir for import export of xml.
  • Min scripts - just setup mediawiki with extensions.

Complete Noobs Docker Wiki Tutorial v0.2

Overview

This tutorial creates a MediaWiki Docker container with:

  • MediaWiki 1.44
  • PageNotice extension (for license notices)
  • YouTube extension (for video embedding)
  • Shared directory for XML import/export

Prerequisites

  • Ubuntu 24.04
  • Docker installed and running
  • Your user in docker group: sudo usermod -aG docker $USER (then logout/login)

Step 1: Create Directory Structure

1.1: Create Project Directory

mkdir ~/completenoobs-docker-v2
cd ~/completenoobs-docker-v2

1.2: Create Shared Directory

mkdir ~/wiki-container

This directory will be used for importing and exporting XML files.

Step 2: Create All Files

2.1: Dockerfile

nano Dockerfile
FROM mediawiki:1.44

# Install dependencies
RUN apt-get update && apt-get install -y \
    mariadb-server \
    python3-pygments \
    curl \
    wget \
    unzip \
    nano \
    vim \
    git \
    && apt-get clean

# Copy setup script
COPY setup_wiki.sh /usr/src/setup_wiki.sh
COPY entrypoint.sh /entrypoint.sh

# Make executable
RUN chmod +x /usr/src/setup_wiki.sh /entrypoint.sh

# Setup wiki
RUN /usr/src/setup_wiki.sh

EXPOSE 80
VOLUME /var/lib/mysql
VOLUME /var/www/html/images
VOLUME /export

ENTRYPOINT ["/entrypoint.sh"]

2.2: Main Setup Script

nano setup_wiki.sh
#!/bin/bash
set -e

echo "Setting up CompleteNoobs Wiki..."

# Initialize MariaDB
if [ ! -d "/var/lib/mysql/mysql" ]; then
    mysql_install_db --user=mysql --datadir=/var/lib/mysql
fi

service mariadb start

# Wait for MariaDB
for i in {1..30}; do
    if mysql -e "SELECT 1;" &>/dev/null; then
        echo "MariaDB ready!"
        break
    fi
    sleep 2
done

# Setup database
mysql -e "CREATE DATABASE IF NOT EXISTS completenoobs_wiki CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -e "CREATE USER IF NOT EXISTS 'wikiuser'@'127.0.0.1' IDENTIFIED BY 'wikipass';"
mysql -e "GRANT ALL PRIVILEGES ON completenoobs_wiki.* TO 'wikiuser'@'127.0.0.1';"
mysql -e "CREATE USER IF NOT EXISTS 'wikiuser'@'localhost' IDENTIFIED BY 'wikipass';"
mysql -e "GRANT ALL PRIVILEGES ON completenoobs_wiki.* TO 'wikiuser'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"

# Install MediaWiki
cd /var/www/html
php maintenance/install.php \
    --dbtype=mysql \
    --dbserver=127.0.0.1 \
    --dbname=completenoobs_wiki \
    --dbuser=wikiuser \
    --dbpass=wikipass \
    --server="http://localhost:8080" \
    --scriptpath="" \
    --lang=en \
    --pass=AdminPass123! \
    "CompleteNoobs Wiki" \
    "admin"

# Download and install extensions
cd extensions/
echo "Installing PageNotice extension..."
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PageNotice --branch REL1_44 || echo "PageNotice download failed, continuing..."

echo "Installing YouTube extension..."
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/YouTube --branch REL1_44 || echo "YouTube download failed, continuing..."

cd /var/www/html

# Configure LocalSettings.php
cat >> LocalSettings.php << 'EOF'

# Basic settings
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgDefaultSkin = "vector-2022";
$wgAllowExternalImages = true;

# Debug settings (remove in production)
$wgShowExceptionDetails = true;
$wgDebugLogFile = "/tmp/mediawiki-debug.log";

# PageNotice extension
if ( file_exists( "$IP/extensions/PageNotice/extension.json" ) ) {
    wfLoadExtension( 'PageNotice' );
}

# YouTube extension
if ( file_exists( "$IP/extensions/YouTube/extension.json" ) ) {
    wfLoadExtension( 'YouTube' );
}

# SyntaxHighlight (usually bundled)
if ( file_exists( "$IP/extensions/SyntaxHighlight_GeSHi/extension.json" ) ) {
    wfLoadExtension( 'SyntaxHighlight_GeSHi' );
    $wgPygmentizePath = '/usr/bin/pygmentize';
}
EOF

# Create helper scripts
cat > /var/www/html/export_wiki.sh << 'EXPORT_EOF'
#!/bin/bash
echo "=== Wiki Export Tool ==="
DATE=$(date +%Y%m%d)
OUTPUT_FILE="/export/${DATE}_wiki_export.xml"

echo "Exporting wiki to: $OUTPUT_FILE"
php /var/www/html/maintenance/run.php dumpBackup.php --full --output=file:$OUTPUT_FILE

if [ -f "$OUTPUT_FILE" ]; then
    echo "Export successful!"
    echo "File saved to: $OUTPUT_FILE"
    echo "On host system: ~/wiki-container/${DATE}_wiki_export.xml"
else
    echo "Export failed!"
fi
EXPORT_EOF
chmod +x /var/www/html/export_wiki.sh

cat > /var/www/html/import_wiki.sh << 'IMPORT_EOF'
#!/bin/bash
echo "=== Wiki Import Tool ==="
echo ""
echo "Available XML files in /export:"
ls -la /export/*.xml 2>/dev/null || echo "No XML files found"
echo ""

if [ -z "$1" ]; then
    echo "Usage: /var/www/html/import_wiki.sh <filename>"
    echo "Example: /var/www/html/import_wiki.sh /export/wiki.xml"
    exit 1
fi

if [ ! -f "$1" ]; then
    echo "Error: File $1 not found!"
    exit 1
fi

echo "Importing from: $1"
echo "This may take several minutes..."

php /var/www/html/maintenance/run.php importDump.php "$1"

if [ $? -eq 0 ]; then
    echo "Import completed!"
    echo "Rebuilding indexes..."
    php /var/www/html/maintenance/run.php rebuildrecentchanges.php
    php /var/www/html/maintenance/run.php initSiteStats.php
    echo "Done!"
else
    echo "Import failed! Check /tmp/mediawiki-debug.log for details"
fi
IMPORT_EOF
chmod +x /var/www/html/import_wiki.sh

# Create status check script
cat > /var/www/html/check_status.sh << 'STATUS_EOF'
#!/bin/bash
cd /var/www/html
echo "=== Wiki Status ==="
echo "Pages: $(mysql --user=wikiuser --password=wikipass completenoobs_wiki -e "SELECT COUNT(*) FROM page;" -s -N 2>/dev/null || echo "Error")"
echo "Users: $(mysql --user=wikiuser --password=wikipass completenoobs_wiki -e "SELECT COUNT(*) FROM user WHERE user_id > 0;" -s -N 2>/dev/null || echo "Error")"
echo ""
echo "=== Extensions ==="
if [ -d "extensions/PageNotice" ]; then
    echo "PageNotice: Installed ✓"
else
    echo "PageNotice: Not installed ✗"
fi
if [ -d "extensions/YouTube" ]; then
    echo "YouTube: Installed ✓"
else
    echo "YouTube: Not installed ✗"
fi
if [ -d "extensions/SyntaxHighlight_GeSHi" ]; then
    echo "SyntaxHighlight: Installed ✓"
else
    echo "SyntaxHighlight: Not installed ✗"
fi
echo ""
echo "=== Shared Directory ==="
if [ -d "/export" ]; then
    echo "/export mounted ✓"
    echo "Files in /export:"
    ls -la /export/*.xml 2>/dev/null || echo "  No XML files"
else
    echo "/export not mounted ✗"
fi
STATUS_EOF
chmod +x /var/www/html/check_status.sh

echo ""
echo "Setup completed!"
echo "Admin: admin / AdminPass123!"

service mariadb stop

2.3: Entrypoint Script

nano entrypoint.sh
#!/bin/bash

echo "Starting CompleteNoobs Wiki..."

service mariadb start

# Wait for MariaDB
for i in {1..30}; do
    if mysql -e "SELECT 1;" &>/dev/null; then
        echo "MariaDB ready!"
        break
    fi
    sleep 1
done

echo ""
echo "========================================="
echo "CompleteNoobs Wiki v0.2 Ready!"
echo "========================================="
echo ""
echo "Access: http://localhost:8080"
echo "Admin: admin / AdminPass123!"
echo ""
echo "Features:"
echo "- MediaWiki 1.44"
echo "- PageNotice extension"
echo "- YouTube extension"
echo "- SyntaxHighlight extension"
echo "- Import/Export via ~/wiki-container"
echo ""
echo "Available commands:"
echo "- Export wiki: docker exec completenoobs_wiki /var/www/html/export_wiki.sh"
echo "- Import XML: docker exec completenoobs_wiki /var/www/html/import_wiki.sh /export/filename.xml"
echo "- Check status: docker exec completenoobs_wiki /var/www/html/check_status.sh"
echo ""

apache2-foreground

Step 3: Build and Run

3.1: Build the Image

docker build -t completenoobs/wiki:v0.2 .

3.2: Run the Container with Shared Directory

docker run -d -p 8080:80 \
  -v ~/wiki-container:/export \
  -v completenoobs_mysql:/var/lib/mysql \
  -v completenoobs_images:/var/www/html/images \
  --name completenoobs_wiki \
  completenoobs/wiki:v0.2

Step 4: Import/Export Operations

4.1: Import an XML File

Place XML file in shared directory

# Copy your XML file to the shared directory
cp ~/Downloads/completenoobs.xml ~/wiki-container/

Import the file

  • All files in host wiki-container directory will also be in the containers /export/ directory.
# Run the import command
docker exec completenoobs_wiki /var/www/html/import_wiki.sh /export/completenoobs.xml

Restore the completenoobs Main Page:

By default, the completenoobs MediaWiki instance overwrites the Main Page with content like "MediaWiki has been installed." To revert to the page’s state before this change, undo the initial revision:

1. Go to http://localhost:8080 in your browser.
2. On the Main Page, click View History (top-right corner).
3. Find the top revision by MediaWiki default and click Undo.
4. Scroll down and click Save changes to revert the Main Page.

4.2: Export Your Wiki

# Export wiki to dated XML file
docker exec completenoobs_wiki /var/www/html/export_wiki.sh

# Check the exported file
ls -la ~/wiki-container/

4.3: Manual Import/Export (Advanced)

Access container shell

docker exec -it completenoobs_wiki bash

Manual export with custom filename

php /var/www/html/maintenance/run.php dumpBackup.php --full --output=file:/export/my_wiki_backup.xml
exit

Manual import with options

# Basic import
php /var/www/html/maintenance/run.php importDump.php /export/wiki.xml

# Import with image uploads
php /var/www/html/maintenance/run.php importDump.php --uploads /export/wiki.xml

# Then rebuild indexes
php /var/www/html/maintenance/run.php rebuildall.php
exit

Step 5: Testing and Verification

5.1: Check Wiki Status

docker exec completenoobs_wiki /var/www/html/check_status.sh

5.2: Test Extensions

1. Visit http://localhost:8080 2. Login with admin / AdminPass123! 3. Create or edit a page and test:

* YouTube: Add/Test <youtube>gBML6zuUpK0</youtube>

  * SyntaxHighlight: Add <syntaxhighlight lang="python">print("Hello")</syntaxhighlight>

5.3: View Logs

# Container logs
docker logs completenoobs_wiki

# MediaWiki debug log
docker exec completenoobs_wiki tail -f /tmp/mediawiki-debug.log

Step 6: Common Operations

6.1: Change Admin Password

Via Web Interface

1. Login at http://localhost:8080 2. Click username → Preferences 3. Go to Password tab 4. Change password

Via Terminal

docker exec -it completenoobs_wiki bash
php /var/www/html/maintenance/run.php changePassword.php --user=admin --password=NEWPASSWORD
exit

6.2: Backup Your Wiki

# Create dated backup
docker exec completenoobs_wiki /var/www/html/export_wiki.sh

# Copy to safe location
cp ~/wiki-container/*_wiki_export.xml ~/backups/

6.3: Restore from Backup

# Place backup in shared directory
cp ~/backups/20250101_wiki_export.xml ~/wiki-container/

# Import the backup
docker exec completenoobs_wiki /var/www/html/import_wiki.sh /export/20250101_wiki_export.xml

6.4: Complete Reset

# Stop and remove container
docker stop completenoobs_wiki
docker rm completenoobs_wiki

# Remove volumes (WARNING: This deletes all data!)
docker volume rm completenoobs_mysql completenoobs_images

# Rebuild and start fresh
docker run -d -p 8080:80 \
  -v ~/wiki-container:/export \
  -v completenoobs_mysql:/var/lib/mysql \
  -v completenoobs_images:/var/www/html/images \
  --name completenoobs_wiki \
  completenoobs/wiki:v0.2

Troubleshooting

Permission Issues

If you encounter permission errors with the shared directory:

# Fix permissions on host
chmod 777 ~/wiki-container

Import Failures

If imports fail, check:

  • File exists in ~/wiki-container
  • File is valid XML format
  • Sufficient disk space
  • Check debug log: docker exec completenoobs_wiki tail /tmp/mediawiki-debug.log

Container Won't Start

# Check logs
docker logs completenoobs_wiki

# Try interactive mode
docker run -it --rm completenoobs/wiki:v0.2 bash

Summary

This setup provides:

  • Clean MediaWiki 1.44 installation
  • Essential extensions (PageNotice, YouTube, SyntaxHighlight)
  • Simple import/export via ~/wiki-container directory
  • No automatic updates - full control over your content
  • Easy backup and restore capabilities

The shared directory approach gives you complete control over when and what to import/export, making it ideal for:

  • Migrating content between wikis
  • Regular backups
  • Sharing wiki content
  • Testing imports before applying to production