This repository contains the information necessary to deploy the RopeWiki technical infrastructure (though it does not
contain the database content nor the images
folder content of the real site).
backupreader
usersExecute the steps below to produce a server running RopeWiki. The instructions assume an Ubuntu machine. On Windows, the
easiest option is probably to install VirtualBox and host a virtual Ubuntu
system. Alternately, all of the steps after the firewall (which can be skipped) should be possible directly in a Windows
command prompt as long as Python 3 is installed and added to
the PATH
(python3 --version
to verify). Ignore all apt
commands and instead perform the Windows alternative.
sudo ufw default deny incoming
)sudo ufw default allow outgoing
)sudo ufw allow OpenSSH
)sudo ufw allow 80/tcp && ufw allow 443/tcp
)sudo ufw allow 22001/tcp && ufw allow 22002/tcp
)sudo ufw allow 8080/tcp
)/etc/ufw/user.rules
/etc/ufw/user6.rules
sudo ufw enable
)sudo apt-get update
)sudo apt update && apt install rng-tools
(note: this may no longer be necessary with docker compose v2)docker compose version
; result should be 2.x.xsudo apt-get install git
)/rw
)/rw/mount
) and define folders relative to that
folderexample
)python3 deploy_tool.py <SITE_NAME> get_sql_backup_legacy
images
folder
python3 deploy_tool.py <SITE_NAME> get_images_legacy
~/rw_passwords.sh
(or another location) with content like:
#!/bin/bash
# These are the manditory environment variables needed to start a copy of the site
export WG_DB_PASSWORD=<The password for the `ropewiki` DB user>
export RW_ROOT_DB_PASSWORD=<The password for the `root` DB user>
export RW_SMTP_USERNAME=<The username for logging into the smtp relay>
export RW_SMTP_PASSWORD=<The password for logging into the smtp relay>
python3 deploy_tool.py <SITE_NAME> dc build
source ~/rw_passwords.sh
python3 deploy_tool.py <SITE_NAME> create_db
python3 deploy_tool.py <SITE_NAME> restore_db
python3 deploy_tool.py <SITE_NAME> restore_empty_db
python3 deploy_tool.py <SITE_NAME> start_site
http://<hostname>:8080
http://<hostname>
python3 deploy_tool.py <SITE_NAME> enable_tls
${proxy_config_folder}/letsencrypt
; select option 1 to reinstall the
existing cert if promptedhttps://<hostname>
python3 deploy_tool.py <SITE_NAME> add_cert_cronjob
crontab -e
Direct SSH access is provided to the backup manager at port 22001 for
the backupreader
user for clients who possess the private key to any of the public keys listed
in authorized_keys.
In the backup manager, the backupreader
's home directory has a backups
folder where complete backups of the database
will be created daily and named all-backup-YYYY-MM-DD-HHMMSS.tar.gz
. An off-site backup client should connect to this
container and copy the latest all-backup
file to back up the database.
In the backup manager, the backupreader
's home directory has a symlink to the images
folder which contains most
of the file-based data uploaded to the site. An off-site backup client should connect to this container and
synchronize the full content of the images
folder to back them up.
This should be performed by a cron job, but in the event of needing to do it manually,
run python3 deploy_tool.py <SITE_NAME> renew_certs
The docker-compose.yaml configuration requires a number of environment variables to be set before it can be used. To
avoid the need to set these variables yourself (apart from WG_DB_PASSWORD and RW_ROOT_DB_PASSWORD), use
python3 deploy_tool.py <SITE_NAME> dc "<YOUR COMMAND>"
. For instance, python3 deploy_tool.py dev dc "up -d"
.
To deploy changes to the webserver Dockerfile: python3 deploy_tool.py redeploy webserver
OR, manually:
docker image build -t ropewiki/webserver .
from the root of this repo)python3 deploy_tool.py <SITE_NAME> dc "rm -f -s -v ropewiki_webserver"
)python3 deploy_tool.py <SITE_NAME> start_site
)Reset the containers and redeploy:
python3 deploy_tool.py <SITE_NAME> dc "down -v"
)python3 deploy_tool.py <SITE_NAME> start_site
)python3 deploy_tool.py <SITE_NAME> enable_tls
then run the specified script, choosing to reinstall
the certificate)If this is accompanied by "(Cannot contact the database server)", it means the MediaWiki app (the ropewiki_webserver container) is not configured properly to contact the database (the ropewiki_db container). The most likely problem is that you have not specified the WG_DB_PASSWORD environment variable to match the one in the database backup you restored. WG_DB_PASSWORD should be specified to match the password used in the database you restored; see instructions above.
To verify whether a connection with a particular username and password can be established, open a terminal in the
database container: docker container exec -it dev_ropewiki_db_1 /bin/bash
(but with an appropriate
container; python3 deploy_tool.py <SITE_NAME> dc ps
to list containers). Then, attempt to connect to the database
with mysql -u <USERNAME> -p<PASSWORD
. If successful, check users with select host, user, password from mysql.user;
.
If the above is successful, verify that the connection can be made from the webserver container by opening a terminal in
the webserver container via a similar process as above. Add the hostname to the mysql
command
like: mysql -h ropewiki_db -u <USERNAME> -p<PASSWORD>
.
These instructions can be used to run a local development instance with just a few adjustments. Simply make sure there
is a site_config appropriate to your local machine, and otherwise follow the instructions above normally. The
site_config "local
" is excluded from git tracking, so it is an ideal place to define a system configuration that other
people are unlikely to use. However, if your local development instance setup is likely to be reusable by others, feel
free to add it to site_configs; a local_windows.json
site_config would probably be helpful to others, for instance.
Note that, in all cases, the following resources (not included in this repo) are necessary to bring up a functional site:
images
folder of the site (18.3+ GB)TLS is not necessary, and sometimes not feasible, on a local development instance. In that case, simply don't enable TLS
and instead access the site with http
. If the site_config hostname
is localhost
, then port 80 will be used and the
site should be accessible at http://localhost
. To use a different port, specify, e.g., a hostname
of localhost:8081
making the site available at http://localhost:8081
. Do not use port 8080 because it is already
used to provide debug access directly to the webserver without going through the reverse_proxy.
_The commands below assume the use of the local
SITE_NAME/siteconfig; change the commands to reflect your site
configuration name if necessary.
python3 deploy_tool.py local dc logs ropewiki_webserver
python3 deploy_tool.py local dc ps
docker container exec -it local_ropewiki_webserver_1 /bin/bash
(but substitute your webserver container name)cat /var/log/nginx/access.log
cat /var/log/nginx/error.log
python3 deploy_tool.py local dc down
docker system df -v
docker volume rm `docker volume ls -q -f dangling=true`