Disclaimer: many links in this post are referral links. If you are uncomfortable with that, just search for the text in the links and use the results from the search engines.
For example, let it be Digital Ocean.
You need to create a $5 basic droplet with Ubuntu 20.04 (Droplets -> Create droplet). Choose:
One can register a domain name at the registrar of your choice. For Russian domains, I use reg.ru.
After registration (and some wait time, while DNS records are being updated across the world), add a resource record in the DNS editor: A for IPv4 and AAAA for IPv6. You can find the IPs on the virtual machine info page.
More about resource records: https://en.wikipedia.org/wiki/List_of_DNS_record_types
For installation of Docker use the official doc:
1# run as root
2apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
3curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4apt-key fingerprint 0EBFCD88
5add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
6apt update && apt install docker-ce docker-ce-cli containerd.io
And install docker-compose by the official doc:
1# run as root
2curl -L "https://github.com/docker/compose/releases/download/1.28.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
3chmod +x /usr/local/bin/docker-compose
You need to choose a wiki to install. Let it be Dokuwiki.
All you need is just a single docker-compose.yaml:
1version: "3.4"
2services:
3 proxy:
4 image: traefik:v2.0
5 container_name: proxy
6 restart: always
7 command:
8 - "--providers.docker=true"
9 - "--providers.docker.exposedbydefault=false"
10 - "--entrypoints.web.address=:80"
11 - "--entrypoints.websecure.address=:443"
12 - "--certificatesresolvers.lech.acme.tlschallenge=true"
13 - "--certificatesresolvers.lech.acme.email=blog@bikulov.org"
14 - "--certificatesresolvers.lech.acme.storage=/letsencrypt/acme.json"
15 labels:
16 - "traefik.enable=true"
17 - "traefik.http.routers.https-redirect.entrypoints=web"
18 - "traefik.http.routers.https-redirect.rule=HostRegexp(`{any:.*}`)"
19 - "traefik.http.routers.https-redirect.middlewares=https-redirect"
20 - "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
21 ports:
22 - "443:443"
23 - "80:80"
24 volumes:
25 - proxy-data:/letsencrypt
26 - /var/run/docker.sock:/var/run/docker.sock:ro
27
28 dokuwiki:
29 image: linuxserver/dokuwiki
30 container_name: dokuwiki
31 restart: always
32 labels:
33 - "traefik.enable=true"
34 - "traefik.http.routers.dokuwiki.rule=Host(`wiki.bikulov.org`)"
35 - "traefik.http.routers.dokuwiki.entrypoints=websecure"
36 - "traefik.http.routers.dokuwiki.tls.certresolver=lech"
37 environment:
38 - PUID=1000
39 - PGID=1000
40 - TZ=Europe/Moscow
41 volumes:
42 - dokuwiki-data:/config
43
44volumes:
45 proxy-data:
46 dokuwiki-data:
You need to change:
certificatesresolvers.lech.acme.email to your emailtraefik.http.routers.dokuwiki.rule to your hostThere are two services, proxy and dokuwiki, with two data volumes. proxy knows about dokuwiki via labels. Only proxy exposes ports 80 and 443 to the host machine and routes traffic to dokuwiki by matching the rule Host(`wiki.bikulov.org`).
Just run in the directory with the yaml:
1docker-compose up -d
More about docker-compose. More about data volumes. More about traefik.
More on backups can be found in the official doc. Below I provide the most essential: the backup bash command.
Backup:
1docker run --rm --volumes-from dokuwiki -v $(pwd):/backup ubuntu bash -c "tar cvfz /backup/dokuwiki_$(date +%s).tar.gz /config"
Restore:
1docker run --rm --volumes-from dokuwiki -v $(pwd):/backup ubuntu bash -c "cd /config && rm -rf * && tar xvf /backup/backup.tar --strip 1"
So, the last building block is to sync the tars from the server elsewhere. You can achieve it with Syncthing, Yandex Disk, rclone, and many others.