Self-hosting deployment with podman(docker) all-in-one

Overview


The all-in-one container provides a easy way to deploy MWiki with everything pre configured, including Mwiki server and Caddy web server in a single docker or podman container. Caddy web server is used for serving static files and providing TLS (Transport Layer Security), also known as SSL - Socket Layer Security, by encrypting the network traffic between the server and a client web browser.

Build the podman or docker image


Clone the repository and enter its root folder.

git clone https://github.com/caiorss/mwiki && cd mwiki

Build the container image using podman (recommended).

podman build -t mwiki  --file docker/all-in-one.Dockerfile .

Build the container image using docker.

docker build -t mwiki  --file docker/all-in-one.Dockerfile .

Create and run the container


Set the environment variables.

export MWIKI_WEBSISTE="https://mydomain.com"
export MWIKI_URL="https://mydomain.com"
export MWIKI_FOLDER=/home/username/wiki

If the websiste is not public use

export MWIKI_PUBLIC=false

If the website is public (anyone can view), set the environment variable MWIKI_PUBLIC to true. The default value of this setting is false.

export MWIKI_PUBLIC=true

Set the Wiki name (website name).

export MWIKI_SITENAME=MBook

Create the container

Make sure that the firewall allows network traffic through the TCP ports 80 (HTTP) and 443 (HTTPS) before running this command.

podman run --name= -it --rm \
    --publish=80:80 --publish=443:443  \
    --env MWIKI_URL=$MWIKI_URL \
    --env=MWIKI_SITENAME=$MWIKI_SITENAME \
    --env=MWIKI_PUBLIC=$MWIKI_PUBLIC \
    --env MWIKI_WEBSITE="$MWIKI_WEBSITE" \
    --volume $MWIKI_FOLDER:/wiki mwiki

Now, the website will be available at

To deploy on local host set the website environment variable to

export MWIKI_WEBSITE="localhost http://[MACHINE-HOSTNAME].local"

The machine hostname can be obtained using the commmand $ hostname on Windows, Linux and other Unix-like operating systems.

$ hostname
dummy

So, the url of this dummy machine on the local network would be

Logging in

It is possible to log in without password by using a temporary magic hyperlink using the command

$ podman exec -it mwiki mwiki-auth
Copy and paste the following URL in the web browser to authenticate.

  https://mydomain.com/auth?token=eyJ1c2VyIjogImFkbWluIiwgInNhbHQiOiAxNzQsICJleHBpcmF0aW9uIjogMTc2OTA4MDU0NiwgInNpZ25hdHVyZSI6ICIxNTVlZDYxOTRhYTE5MTNmMzhkYWMzODI3ZTJiZTdiNzdiNGQ0NzVhYzVjMmJlNDU2ZTY5ZmViNTRiOTg0OGU4In0%3D

Or paste the following token in the log in form https://mydomain.com

 eyJ1c2VyIjogImFkbWluIiwgInNhbHQiOiAxNzQsICJleHBpcmF0aW9uIjogMTc2OTA4MDU0NiwgInNpZ25hdHVyZSI6ICIxNTVlZDYxOTRhYTE5MTNmMzhkYWMzODI3ZTJiZTdiNzdiNGQ0NzVhYzVjMmJlNDU2ZTY5ZmViNTRiOTg0OGU4In0=

NOTE: This URL is only valid for 20 seconds.
NOTE: If MWiki URL is not correct, set the environment variable $MWIKI_URL to the app URL.For instance, in bash Unix shell $ export MWIKI_URL=https://mydomain.com before running this comamnd again.

Then, copy this url to the web browser to log in. Note that the magic login link is valid only for 20 seconds. After this step, the user can set the administrator password. MWiki does not use a hardcoded default password, instead it generates a random default password for every wiki.