Guide
On a VPS with Traefik
Preparing the VPS, installing the project, filling docker/.env, starting and checking with curl.
What it is about
On the VPS run Docker and Traefik. Traefik takes the requests on port 443, fetches the certificate from Let's Encrypt and passes them to the container. Nobody sees port 3370 from outside. The VPS builds nothing; it pulls the image from the registry, see The image.
At the end the container henniokf runs, and the application answers at
https://<subdomain>.<domain>. Precondition: the workflow "Image" has
published an image at least once. All commands run as root on the VPS. If
you work in a web console, read In a web console first.
Step 1: prepare the VPS
A VPS with Ubuntu, Docker and Traefik; many providers offer a ready image "Ubuntu with Docker and Traefik". In the firewall only 22, 80 and 443 are open. For the subdomain, records A and AAAA in the DNS point to the VPS.
The Compose file must know three names of Traefik: its network, its entry point for HTTPS and its certificate resolver. On the VPS:
docker ps --format '{{.Names}} {{.Image}}' | grep -i traefik
The first column is the name of the container, below <traefik-container>:
docker inspect <traefik-container> --format '{{range $n, $_ := .NetworkSettings.Networks}}{{$n}} {{end}}'
docker inspect <traefik-container> --format '{{join .Args " "}}' | tr ' ' '\n' | grep -E 'entrypoints|certresolver'
| Variable | Default | What |
|---|---|---|
TRAEFIK_NETWORK | traefik-proxy | the network of Traefik; the Compose file joins it as external |
TRAEFIK_ENTRYPOINT | websecure | the entry point for HTTPS |
TRAEFIK_CERTRESOLVER | letsencrypt | the certificate resolver |
If the commands show other names, they belong into docker/.env.
Router, service, container and Compose project are called henniokf.
Several projects on one VPS therefore do not disturb each other, as long as
each has its own name.
Step 2: the root directory
The container runs as UID 1000, so the directory belongs to UID 1000:
mkdir -p /srv/henniokf && chown 1000:1000 /srv/henniokf
Step 3: clone
git clone https://github.com/arpablo/henniokf.git /opt/henniokf
While the repository is private, Git asks for username and password: your
username on GitHub and as password a fine-grained token with "Contents:
Read-only" for this repository only. The token never goes into the address.
From the clone the VPS needs only docker/compose.vps.yml,
docker/vps.env.example and docker/backup.sh.
Step 4: docker/.env
cd /opt/henniokf && cp docker/vps.env.example docker/.env && chmod 600 docker/.env && nano docker/.env
| Variable | Value |
|---|---|
HENNIOKF_HOST | <subdomain>.<domain>, without https://, required |
HENNIOKF_DATA | /srv/henniokf |
HENNIOKF_SYNC_TOKEN | a random word from openssl rand -hex 32, required. It creates the first admin |
HENNIOKF_IMAGE | optionally a fixed state; otherwise the line stays commented out |
TRAEFIK_NETWORK, TRAEFIK_ENTRYPOINT, TRAEFIK_CERTRESOLVER | the names from step 1 |
From them the Compose file sets HENNIOKF_URL to https:// and the host,
the main address for passkeys. docker/.env stays on the VPS, is in
.gitignore and never in the repository. Whoever may read the file knows
the token, hence chmod 600.
Further settings of the application, such as HENNIOKF_SIGN_IN_LIMIT, come
as a line under environment in docker/compose.vps.yml. An example stands
there as a comment.
Step 5: log in to the registry
While the image is private, the VPS logs in once with a token (classic)
with only read:packages. A fine-grained token cannot read the registry.
docker login ghcr.io -u <github-user>
At "Password" paste the token. It stays in /root/.docker/config.json and
applies to every later pull. Once the image is public after the open-source
release, this step falls away.
Step 6: start
docker compose -f /opt/henniokf/docker/compose.vps.yml up -d
Compose pulls the image (pull_policy: always), attaches the container to
the network of Traefik and starts it. Traefik fetches the certificate at the
first call.
Step 7: check with curl
curl -s -o /dev/null -w '%{http_code}\n' https://<subdomain>.<domain>/sign-in
curl -s -o /dev/null -w '%{http_code}\n' https://<subdomain>.<domain>/account
| Answer | Meaning |
|---|---|
200 for /sign-in and for / | the application runs; reading is public |
401 for /account without Accept: text/html | right: the sign-in requirement works, curl is no browser |
307 for /account with Accept: text/html | right: a page leads to /sign-in |
| 502 right after the start | too early, wait a few seconds |
| 502 also after a minute | look into the log: docker logs henniokf |
| 404 | host or entry point in docker/.env is wrong |
Step 8: the first admin
Open https://<subdomain>.<domain>/sign-in in the browser and create the
first admin with the token from docker/.env, see
The first admin. Afterwards /status
shows the commit of the image under "Version".
Next: Operation and backup.