- This is forked from crazy-max/docker-dokuwiki
- Backup to Git repo is based on ericbarch/dockuwiki
- It is Docker image of DokuWiki behind Traefik
- It uses Traefik Docker image
- Traefik is used as reverse proxy and for unattended creation/renewal of Let's Encrypt certificates
- Upgrade to Release 2020-07-29 Hogfather
- Follow Alpine DokuWiki Installation documentation
- Used before this change the common
docker-compose.ymlfile is separated now to one for 'docuwiki' application container (docker-compose.yml) and dedicated one for 'traefik' container (traefik/docker-compose.yml) - Due to this change you can now run 'traefik' container independently from 'dokuwiki' application container, which can be useful in case you already have 'traefik' container running as an edge proxy for other application containers
- The only common configuration item which needs to be shared between 'traefik' container and its served application containers is the name of their common network defined by
COMMON_NETWORKvariable, see below
- The only common configuration item which needs to be shared between 'traefik' container and its served application containers is the name of their common network defined by
- The given 'traefik'
docker-compose.ymlfile (traefik/docker-compose.yml) can be used as an example, in case you'd like to run 'dokuwiki' application container on fresh docker system, as described below
- Alpine Linux 3.9, Nginx, PHP 7.2, ACME Let's Encrypt via Traefik
- Tarball authenticity checked during building process
- OPCache enabled to store precompiled script bytecode in shared memory
- Data, configuration, plugins, and templates are backed up to a configured Git repo
- Variables defined in
.envfileDOKUWIKI_TRAEFIK_FE_RULEtraefikfrontend rule- set default to
Host:wiki.example.comindocker-compose.yml - used in
docker-compose.yml, if not defined traffic will not be routed todokuwikicontainer - example
DOKUWIKI_TRAEFIK_FE_RULE=Host:wiki.example.com
PERSISTENT_DIR- host persistent volume to store DockuWiki site data, ACME Let's Encrypt certificates, and a pravite key of your Git backup server account
- set default to
/opt/docker/persistentinpre-deploy.sh - set default to
/opt/docker/persistentindocker-compose.yml - used by
pre-deploy.shto create host persistent volumes directory structure - used in
docker-compose.ymlandtraefik/docker-compose.ymlto define persistent volumes - example
PERSISTENT_DIR=/opt/docker/persistent
ACME_EMAIL- email address used for ACME (Let's Encrypt) registration
- set default to
webmaster@example.comintraefik/docker-compose.yml - used in
traefik/docker-compose.ymlto defineacmeemail address, if not defined Let's Encrypt will not work correctly - example
ACME_EMAIL=webmaster@example.com
DOCKER_DOMAIN- default base domain name used for the frontend rules
- set default to
docker.localhostintraefik/docker-compose.yml - used in
traefik/docker-compose.ymlto define base domain name for frontend rules for hosts which are not full domain name - example
DOCKER_DOMAIN=docker.localhost
COMMON_NETWORK- name of the network common for
traefikand its served containers - set default to
traefik-public-networkindocker-compose.yml - set default to
traefik-public-networkintraefik/docker-compose.yml - used in
docker-compose.ymlandtraefik/docker-compose.ymlto define the name of the docker bridged network for connectivity - example
COMMON_NETWORK=traefik-public-network
- name of the network common for
BACKUP_USER_EMAIL- backup user email address
- used to mark generated public key to be added to the account used to access Git backup repo
- used to configure Git global option
user.emailand deriveuser.name(as the part of the email address before '@' sign) for Git commands used to commit backup data to Git backup repo - used in container ENTRYPOINT
- passed from
docker-composeto container ENTRYPOINT - set default to
dokuwiki-backup@example.comindocker-compose.yml - set default to
dokuwiki-backup@example.comin container ENTRYPOINT if passed empty - example
BACKUP_USER_EMAIL=dokuwiki-backup@example.com
GIT_BACKUP_REPO_URL- Git remote URL of your repo on Git server to backup wiki content
- Git associates a remote URL with a name, which is called
originby default, and for which you can get the URL with the following command (run within your repo directory)git remote get-url origin
- Git associates a remote URL with a name, which is called
- mandatory and validated in
pre-deploy.shscript and in container ENTRYPOINT - passed by
docker-composeto container ENTRYPOINT - example
GIT_BACKUP_REPO_URL=git@bitbucket.org:username/reponame.git
- Git remote URL of your repo on Git server to backup wiki content
TZ- container timezone
- used in container ENTRYPOINT
- set default to
Europe/Luxembourgindocker-compose.yml - passed from
docker-composeto container ENTRYPOINT - set default to
UTCin container ENTRYPOINT if passed empty - example
TZ=Europe/Oslo
- The following variable have defaults and used in container ENTRYPOINT. You can redefine them in
.envand they will be passed as is to container ENTRYPOINT bydocker-composeMEMORY_LIMIT- PHP memory limit
- default to
256M - example
MEMORY_LIMIT=256M
UPLOAD_MAX_SIZE- Upload max size
- default to
16M - example
UPLOAD_MAX_SIZE=16M
OPCACHE_MEM_SIZE- PHP OpCache memory consumption
- default to
128 - example
OPCACHE_MEM_SIZE=128
- DokuWiki
/data- bind to host${PERSISTENT_DIR}/dokuwiki/datafolder- folder that contains configuration, plugins, templates and data
/root/.ssh- bind to host${PERSISTENT_DIR}/dokuwiki/root/.sshfolder- folder that contains public/private keys,
configandknown_hostsfiles - you can place here the pravite key corresponding to a public key of your Git backup server account, name the file as
id_rsa
- folder that contains public/private keys,
- Traefik
/acme.json- bind to host${PERSISTENT_DIR}/acme.jsonfile- file that contains ACME Let's Encrypt certificates
- Traefik
80- HTTP port - redirects traffic to itself (Traefik) to HTTPS port (443)443- HTTPS port - proxies traffic to DokuWiki to HTTP port (80)
- DokuWiki
80- HTTP port - serves DokuWiki wiki
- On the fresh docker system (if you didn't run this installation procedure before), follow these steps:
- Create project directory,
cdto it, and run the following commands from within this project directory - Create
.envfile with the following environment variables, see the description and examples above
- Create project directory,
DOKUWIKI_TRAEFIK_FE_RULE=Host:wiki.example.com
PERSISTENT_DIR=/opt/docker/persistent
ACME_EMAIL=webmaster@example.com
DOCKER_DOMAIN=docker.localhost
BACKUP_USER_EMAIL=dokuwiki-backup@example.com
GIT_BACKUP_REPO_URL=git@bitbucket.org:username/reponame.git
COMMON_NETWORK=traefik-public-network
TZ=Europe/Oslo
MEMORY_LIMIT=
UPLOAD_MAX_SIZE=
OPCACHE_MEM_SIZE=- Download the pre-deployment script (
pre-deploy.sh), make it executable, and run it
curl -sSL https://raw.githubusercontent.com/mtilson/dokuwiki/master/pre-deploy.sh > pre-deploy.sh
chmod +x pre-deploy.sh
./pre-deploy.sh- Provide access to your Git backup repo via SSH. You can do it the following way
- Generate a public/pravite key pair
- Place the private key to the host persistent volume as
${PERSISTENT_DIR}/dokuwiki/root/.ssh/id_rsa- Make its permissions to be
read/writeonly byroot:sudo chmod 600 ${PERSISTENT_DIR}/dokuwiki/root/.ssh/id_rsa
- Make its permissions to be
- Add the public key to the Git user account which has access to Git backup repo
GIT_BACKUP_REPO_URLvariable defined above specifies Git remote SSH URL address used to access your Git backup repo- Git remote SSH URL addresses have the form
git@<gitserver>:<user>/<repo>.git, which means that user account<user>has access to repository<repo>on Git server<gitserver> - To provide SSH access to your Git backup repo you have to add the generated public key to your
<user>account on the<gitserver>server- See how to set up an SSH key for BitBucket
- See how to connect to GitHub with SSH
- Create the SSH configuration file (
config) in the host persistent volume as${PERSISTENT_DIR}/dokuwiki/root/.ssh/config- Put necessary SSH configuration to the above file, for example like the following
Host bitbucket.org
StrictHostKeyChecking no- Run the following commands to deploy containers and see their logs (use
Ctrl-Cto exit)
docker-compose -f docker-compose.yml -f traefik/docker-compose.yml pull
docker-compose -f docker-compose.yml -f traefik/docker-compose.yml up -d
docker-compose -f docker-compose.yml -f traefik/docker-compose.yml logs -f # to see the container logs in console; Ctrl-C to exit- If you didn't place the private key to the host persistent volume (as
${PERSISTENT_DIR}/dokuwiki/root/.ssh/id_rsa), the container initialization script will generate a public/pravite key pair, store the generated keys in${PERSISTENT_DIR}/dokuwiki/root/.ssh/, and show the public key in the container log, waiting for the access to Git backup repo be provided - see the next point - If the container initialization script is not able to access Git backup repo, it will wait for 10 minutes (or till the moment the access is provided) checking once per minute for the access and asking you to add a public key. Look for the
Please add the public key ...messages in the container log in console - On the first container run (after this installation procedure), fresh DokuWiki data will be
commitedto the configured Git backup repo. On the next container run, DokuWiki data from the Git backup repo will becloned/pulledto the container/datavolume - As script proceeds, point your browser to your wiki site URL to finish with DokuWiki installation wizard, fill in the form provided by the wizard, and click
Save - The following message will appear in your browser
The configuration was finished successfully. You may delete the install.php file now. ...
- Use
Ctrl-Cin console to exit fromdocker-compose logs, delete theinstall.phpfile with the following command:docker exec dokuwiki /bin/sh -c "rm -fr /var/www/install.php"
- If you did installation procedure before and just need to run existing 'dokuwiki' container, run the following command from the project directory (created during installation procedure):
docker-compose -f docker-compose.yml -f traefik/docker-compose.yml pull
docker-compose -f docker-compose.yml -f traefik/docker-compose.yml up -d- Use the the following commands to upgrade containers, it is recommended
docker-compose -f docker-compose.yml -f traefik/docker-compose.yml down
docker-compose -f docker-compose.yml -f traefik/docker-compose.yml pull
docker-compose -f docker-compose.yml -f traefik/docker-compose.yml up -d- You can also upgrade DokuWiki automatically through its UI
- All data in
/datafolder are periodically backed up to the provided Git backup repo - Any time you run a container from this image on any host with configured access to Git backup repo, DokuWiki data from the repo will be synced with the container's
/datavolume and host's${PERSISTENT_DIR}/dokuwiki/datafolder. Usepre-deploy.shscript and the above Installation section to prepare host
- MIT. See
LICENSEfor more details