- 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.yml
file 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_NETWORK
variable, 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.yml
file (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
.env
fileDOKUWIKI_TRAEFIK_FE_RULE
traefik
frontend rule- set default to
Host:wiki.example.com
indocker-compose.yml
- used in
docker-compose.yml
, if not defined traffic will not be routed todokuwiki
container - 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/persistent
inpre-deploy.sh
- set default to
/opt/docker/persistent
indocker-compose.yml
- used by
pre-deploy.sh
to create host persistent volumes directory structure - used in
docker-compose.yml
andtraefik/docker-compose.yml
to define persistent volumes - example
PERSISTENT_DIR=/opt/docker/persistent
ACME_EMAIL
- email address used for ACME (Let's Encrypt) registration
- set default to
[email protected]
intraefik/docker-compose.yml
- used in
traefik/docker-compose.yml
to defineacme
email address, if not defined Let's Encrypt will not work correctly - example
DOCKER_DOMAIN
- default base domain name used for the frontend rules
- set default to
docker.localhost
intraefik/docker-compose.yml
- used in
traefik/docker-compose.yml
to 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
traefik
and its served containers - set default to
traefik-public-network
indocker-compose.yml
- set default to
traefik-public-network
intraefik/docker-compose.yml
- used in
docker-compose.yml
andtraefik/docker-compose.yml
to 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.email
and 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-compose
to container ENTRYPOINT - set default to
[email protected]
indocker-compose.yml
- set default to
[email protected]
in container ENTRYPOINT if passed empty - example
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
origin
by 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.sh
script and in container ENTRYPOINT - passed by
docker-compose
to container ENTRYPOINT - example
[email protected]: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/Luxembourg
indocker-compose.yml
- passed from
docker-compose
to container ENTRYPOINT - set default to
UTC
in container ENTRYPOINT if passed empty - example
TZ=Europe/Oslo
- The following variable have defaults and used in container ENTRYPOINT. You can redefine them in
.env
and they will be passed as is to container ENTRYPOINT bydocker-compose
MEMORY_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/data
folder- folder that contains configuration, plugins, templates and data
/root/.ssh
- bind to host${PERSISTENT_DIR}/dokuwiki/root/.ssh
folder- folder that contains public/private keys,
config
andknown_hosts
files - 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.json
file- 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,
cd
to it, and run the following commands from within this project directory - Create
.env
file 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
[email protected]
DOCKER_DOMAIN=docker.localhost
[email protected]
[email protected]: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/write
only 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_URL
variable 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-C
to 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
commited
to the configured Git backup repo. On the next container run, DokuWiki data from the Git backup repo will becloned/pulled
to the container/data
volume - 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-C
in console to exit fromdocker-compose logs
, delete theinstall.php
file 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
/data
folder 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
/data
volume and host's${PERSISTENT_DIR}/dokuwiki/data
folder. Usepre-deploy.sh
script and the above Installation section to prepare host
- MIT. See
LICENSE
for more details