Assume you have a dump of the database (MediaWiki 1.44) and the images in the backup
directory:
ls backup
full.sql images/
First, create file with secrets using the following command:
cat > .env <<EOF
DB_TYPE=mysql
DB_NAME=mediawiki
DB_USER=wikiuser
DB_PASSWORD=$(openssl rand -hex 16)
DB_ROOT_PASSWORD=$(openssl rand -hex 16)
SERVER=http://localhost
PORT=8080
EOF
Then adjust SERVER
and PORT
variables according to your needs.
Next, fire up the containers:
docker compose up -d
Now, import the database contents (might need to wait a while until the mariadb initialises"
docker exec -i --env-file .env mw-db sh -c 'exec mariadb -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME"' < backup/full.sql
And finally, copy the images:
docker cp backup/images/. mw-app:/var/www/html/images
If you want to run Wiki in production, this assumes you have set up a proper domain name. For MediaWiki to work with that, change $wgServer
in LocalSettings.php
to a proper value like https://webchemwiki.biodata.ceitec.cz
.