Self-host TCKDB
Run your own TCKDB with Docker. A download and two commands give you the database, the object store, the API and the web UI, with every password generated for you.
What you need
curl,bashandopenssl.- Docker Engine or Docker Desktop with Compose v2. Check with
docker compose version. - A 64-bit machine, x86_64 or arm64. The images are built for both, so a Raspberry Pi 4 or 5 on a 64-bit OS works.
- About 5 GB of disk for the images, plus room for your data. Use an SSD, not an SD card.
- 4 GB of RAM. 8 GB is more comfortable.
Install
Run these in order. After the cd, every command on this page runs from
that directory.
VERSION=0.4.1
curl -fLO https://github.com/TCKDB/TCKDB/releases/download/v$VERSION/tckdb-selfhost-$VERSION.tar.gz
curl -fLO https://github.com/TCKDB/TCKDB/releases/download/v$VERSION/tckdb-selfhost-$VERSION.tar.gz.sha256
sha256sum -c tckdb-selfhost-$VERSION.tar.gz.sha256
tar xzf tckdb-selfhost-$VERSION.tar.gz
cd tckdb-selfhost-$VERSION
backend/scripts/ops/tckdb_make_env.sh
docker compose --env-file .env.selfhosted --env-file .env.db-admin \
--profile selfhost up -d --wait
On macOS, check the download with shasum -a 256 -c instead of sha256sum -c.
1. Download the bundle. Each release
carries tckdb-selfhost-<version>.tar.gz: the compose file, the env
templates, the Caddyfile and the scripts, at the same paths as in the
repository. The application itself comes as published images, whose default
tag is the bundle's version.
On a server, use a stable path. Each release unpacks into its own
directory, so point a symlink at the current one and use the symlink in
systemd units, cron jobs and scripts. The example units expect /opt/tckdb:
sudo tar xzf tckdb-selfhost-$VERSION.tar.gz -C /opt
sudo ln -sfn /opt/tckdb-selfhost-$VERSION /opt/tckdb
cd /opt/tckdb
An upgrade then moves the symlink, and nothing that names /opt/tckdb
changes.
From a git checkout. Developers can use a clone instead:
git clone https://github.com/TCKDB/TCKDB.git && cd TCKDB, then the same
two commands. There make selfhost does both in one go, running the env
script only if the env files are missing.
2. Make the env files. tckdb_make_env.sh asks a few questions. Press
Enter to take the default:
| Question | Default |
|---|---|
| Who should reach TCKDB? | this machine only. See Make it reachable for the other three answers |
| Deployment mode | shared_private, or hosted_public for the internet answers (local for a laptop) |
| Administrator username | admin |
| Administrator email | none |
It writes two files, both readable by you only:
.env.selfhostedholds the API's settings and secrets..env.db-adminholds the database admin and owner passwords and the first administrator. The database container and the one-offinitcontainer use it. The API never sees it.
It generates every password and prints the administrator's password once.
Save it. --yes takes every default without asking, each question has a
flag, and --set KEY=VALUE sets anything else, such as
--set TCKDB_WEB_PORT=9011. Run tckdb_make_env.sh --help for the list.
It will not overwrite existing files unless you pass --force.
3. Start the stack. Compose starts the services in this order:
db(Postgres with the RDKit cartridge) andseaweedfs(the S3 object store).initsets up the database roles, runs the migrations, creates the first administrator and exits. It runs on every start. Steps already done are skipped, with one exception: if the first administrator was deactivated,initreactivates it, and if its role was changed,initfails and the API does not start. To retire that account, changeTCKDB_BOOTSTRAP_USERNAMEin.env.db-adminto the account that should stay an administrator.tckdb-apiandfrontendstart onceinithas succeeded.
--wait returns when everything is healthy. The first start downloads the
images. With the images already downloaded, the stack is healthy about 50
seconds after unpacking the bundle.
The stack refuses to start while a secret is empty or still a change-me
placeholder.
What you get
| Address | |
|---|---|
| Web UI | http://127.0.0.1:8011 |
| API | http://127.0.0.1:8010/api/v1 |
| Administrator | the username you chose, with the printed password |
| Data | Compose volumes tckdb_pgdata (database) and tckdb_seaweedfs (files) |
Open the web UI and log in as the administrator. With the default answer every port binds to 127.0.0.1, so nothing is reachable from another machine yet.
Make an API key
Scripts, tckdb-client and ARC send an API key with every upload. Log in
and mint one:
TCKDB_BASE_URL=http://127.0.0.1:8010/api/v1 \
backend/scripts/tckdb_auth.sh login-create-key
source .tckdb_auth.env
The script asks for your username and password, then writes TCKDB_BASE_URL
and TCKDB_API_KEY to .tckdb_auth.env (mode 600). Point any client at
those two values. More users, roles and key handling are on
Admin accounts and API keys.
Check it
backend/scripts/check_selfhosted_deployment.sh
It checks that no secret is a placeholder, that every container is running and healthy, that the RDKit extension is installed, that the database is at the latest migration, and that the API answers. It exits non-zero if any check fails.
Make it reachable
TCKDB starts on this machine only. To let others in, answer the env
script's first question, or pass --access. The script then sets the
address, the cookies and the rate limiter's client header together, and
prints the start command.
| Who reaches it | --access |
Ports opened | Profiles |
|---|---|---|---|
| This machine only | local (default) |
none | selfhost |
| Your lab network | lan |
the web UI port, on the lab address | selfhost |
| The internet, with your domain name | https |
80/tcp, 443/tcp, 443/udp | selfhost, caddy |
| The internet, no open port | cloudflare |
none | selfhost, cloudflare |
The database (5432), the object store (9000) and the API port (8010) stay on
127.0.0.1 in every option. The script records the profiles in
.env.selfhosted as COMPOSE_PROFILES, so make selfhost, and any
docker compose command given no --profile, starts the right services.
1. This machine only
The default. Open http://127.0.0.1:8011.
2. Your lab network
You need this machine's IPv4 address on the lab network. If the machine runs a firewall, allow TCP 8011 from the lab.
backend/scripts/ops/tckdb_make_env.sh --access lan --lan-address 192.168.1.20
docker compose --env-file .env.selfhosted --env-file .env.db-admin \
--profile selfhost up -d --wait
Options 2 and 3 need release 0.3.0 or newer; the default tag is. With 0.2.0 the API
refuses the plain-HTTP cookie setting and does not start, and the web UI passes
on any X-Real-IP a client sends.
Without --lan-address the script offers the address of the default route.
It sets:
TCKDB_WEB_BIND=192.168.1.20. The web UI listens on that address, and no longer on 127.0.0.1.TCKDB_PUBLIC_BASE_URL=http://192.168.1.20:8011/api/v1.TRUSTED_PROXY_HEADER=X-Real-IP. The web UI setsX-Real-IPto the address each lab machine connects from, and drops any value the client sent.SESSION_COOKIE_SECURE=falseandSESSION_COOKIE_ALLOW_PLAIN_HTTP=true. This is plain HTTP, so the login cookie crosses the network unencrypted. Use it only on a network you trust. Otherwise use option 3, or your own proxy with a lab certificate.
Check from another machine on the network:
curl -i http://192.168.1.20:8011/api/v1/health
Then open http://192.168.1.20:8011 and log in.
Docker opens a published port ahead of ufw and firewalld rules. To limit
which machines can connect, filter at the network's firewall or in Docker's
DOCKER-USER chain. The script warns if the address is a public one.
Rootless Docker does not pass on the client's address: every lab machine then looks like one client to the rate limiter.
3. The internet, with your domain name
You need:
- a domain name with a DNS A record (AAAA for IPv6) pointing at the server's public address;
- TCP 80 and 443, and UDP 443, reaching the server from the internet. Let's Encrypt checks the domain on port 80 or 443 before it issues a certificate.
backend/scripts/ops/tckdb_make_env.sh --access https --domain tckdb.example.org \
--acme-email admin@example.org
docker compose --env-file .env.selfhosted --env-file .env.db-admin \
--profile selfhost --profile caddy up -d --wait
Options 2 and 3 need release 0.3.0 or newer; the default tag is.
The caddy profile adds Caddy with
deploy/caddy/Caddyfile. On first start it gets a certificate for the
domain. It renews it, redirects HTTP to HTTPS, and passes every request to
the web UI over the compose network. The web UI port stays on 127.0.0.1.
The script sets TCKDB_DOMAIN, TCKDB_ACME_EMAIL (optional),
TCKDB_PUBLIC_BASE_URL=https://tckdb.example.org/api/v1 and
TRUSTED_PROXY_HEADER=X-Real-IP. Caddy replaces X-Real-IP with the
address it was reached from. The mode is hosted_public; pass
--mode shared_private for a private group server.
Check:
curl -i https://tckdb.example.org/api/v1/health
docker compose --env-file .env.selfhosted --env-file .env.db-admin logs caddy
If no certificate arrives, the Caddy log says why. Usually the DNS record does not point at the server yet, or port 80 or 443 is blocked.
4. The internet, with no open port
A tunnel dials out from the server. No port is opened and the server needs no public address.
Cloudflare Tunnel. You need a domain on Cloudflare and a tunnel: in the
Zero Trust dashboard, Networks → Tunnels → Create a tunnel → Cloudflared.
Copy its token. Give the tunnel a public hostname with the service
http://127.0.0.1:8011.
backend/scripts/ops/tckdb_make_env.sh --access cloudflare --domain tckdb.example.org
docker compose --env-file .env.selfhosted --env-file .env.db-admin \
--profile selfhost --profile cloudflare up -d --wait
The script asks for the token. Without a terminal, add
CLOUDFLARED_TUNNEL_TOKEN=<token> to .env.selfhosted. It sets
TRUSTED_PROXY_HEADER=CF-Connecting-IP, which Cloudflare's edge sets.
Check with curl -i https://tckdb.example.org/api/v1/health.
Public server has the
details.
Tailscale. For devices on your tailnet. You need Tailscale on the server, with MagicDNS and HTTPS certificates turned on for the tailnet.
backend/scripts/ops/tckdb_make_env.sh --public-url https://tckdb.your-tailnet.ts.net
docker compose --env-file .env.selfhosted --env-file .env.db-admin \
--profile selfhost up -d --wait
tailscale serve --bg 8011
tailscale serve gives the web UI an HTTPS address on the tailnet,
https://<machine name>.<tailnet name>.ts.net. Use that address as the
public URL. Leave TRUSTED_PROXY_HEADER unset. Check from another tailnet
device with curl -i https://<machine name>.<tailnet name>.ts.net/api/v1/health.
tailscale funnel --bg 8011 opens the same address to the whole internet.
Your own proxy
Already run nginx, Traefik or an institutional proxy? Keep option 1 and
point the proxy at 127.0.0.1:8011 for the web UI and the API together, or
127.0.0.1:8010 for the API alone.
Set TCKDB_PUBLIC_BASE_URL to the public address, ending in /api/v1. Set
TRUSTED_PROXY_HEADER=X-Real-IP only if the proxy overwrites X-Real-IP
with the client's address. The web UI keeps an X-Real-IP that arrives
from this machine, so a proxy that passes the client's value on lets the
client choose its own rate-limit key. Lab server
has an nginx example.
The web UI trusts X-Real-IP only from its own IPv4 Docker networks, which
is where a connection to 127.0.0.1:8011 arrives from. Point the proxy at
127.0.0.1, not at localhost (which may resolve to ::1) or the
machine's own address. From anywhere else the header is replaced and every
request looks like it came from the proxy.
Change an existing install
Edit .env.selfhosted to match the option: TCKDB_WEB_BIND,
TCKDB_PUBLIC_BASE_URL, TRUSTED_PROXY_HEADER, DEPLOYMENT_MODE, the two
cookie settings, TCKDB_DOMAIN and COMPOSE_PROFILES. Then run up -d --wait
with the option's profiles. Compose recreates the containers whose settings
changed. Don't rerun the script with --force: it makes new database
passwords, which the existing database refuses.
Upgrade
Each release has its own bundle. The data stays in the Compose volumes, and the two env files carry over.
- Back up first.
- Download, check and unpack the new release's bundle beside the old directory, as in Install.
-
Copy
.env.selfhostedand.env.db-adminfrom the old directory into the new one. Don't runtckdb_make_env.shin the new directory: it makes new passwords, which the existing database refuses.The env files carry
COMPOSE_PROJECT_NAME, and that is what makes the new directory use the old volumes: Compose starts every volume name with the project name, which is otherwise the directory's name. Check that.env.selfhostedhas the line. If it has none (files written before the template set it), the new directory would start on new, empty volumes: add the project thatdocker compose lsshows, such asCOMPOSE_PROJECT_NAME=tckdbfor a clone inTCKDB/, before the firstupthere.Copy anything else you made or changed by hand as well:
.tckdb_auth.env(the API key file from Make an API key) and any edit todeploy/caddy/Caddyfile. The new bundle has its own Caddyfile, so carry an edit over rather than the old file. -
If
.env.selfhostedsetsTCKDB_IMAGE_TAG, delete the line or change it to the new release. Unset, the new compose file's default is used, which is the bundle's version. - With a symlink, point it at the new directory:
sudo ln -sfn /opt/tckdb-selfhost-<new version> /opt/tckdb. - In the new directory, run the
up -d --waitcommand again.
init runs the migrations before the new API starts.
From a git checkout. Run git pull, then steps 4 and 6 in the same
directory.
Another image. To run a tag other than the default, set
TCKDB_IMAGE_TAG=<tag> in .env.selfhosted and run up -d --wait. The tag
is a release such as 0.4.1 or sha-<commit>. One tag names both the API and
the web UI image, so a sha- tag must come from a commit that built both. A
release tag always does. Keep the tag in the env file. Passed only on the
command line, it reverts to the compose default on the next up.
To roll back, point the symlink back and run the up -d --wait command from
the old directory, or set the previous tag. If the upgrade ran a migration, restore the database backup
as well.
Back up
Back up three things:
-
The database. This writes a dump to the current directory:
docker compose --env-file .env.selfhosted --env-file .env.db-admin exec -T db \ sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc' > tckdb-$(date +%F).dumpKeep the
-T. Without it Docker allocates a terminal, which corrupts the binary dump. -
The files in SeaweedFS. Copy the bucket with any S3 client, using the endpoint
http://127.0.0.1:9000and theS3_ACCESS_KEY/S3_SECRET_KEYfrom.env.selfhosted. - Both env files. The database roles keep the passwords they were created with, so a restore needs the same files.
Copy the backups to another machine. Scheduled backups, restore and rollback are on Public server.
Stop and remove
docker compose --env-file .env.selfhosted --env-file .env.db-admin \
--profile selfhost down
Pass the same profiles you start with, such as --profile caddy. down
keeps the data. down -v deletes the volumes, and with them every record
and file.
The database passwords are set when the volume is first created. To change
one later, change the role first with ALTER ROLE, then the env file. The
command is in .env.db-admin.example. Use tckdb_make_env.sh --force only
together with a fresh volume.
Good to know
- The
selfhostprofile always uses the bundled SeaweedFS. For an external S3 store (AWS S3, Google Cloud Storage, an existing MinIO), run the API container withbackend/scripts/ops/tckdb_deploy.shinstead. Its header lists the settings;tckdb_deploy.sh --helpprints it, as--helpdoes for every script inbackend/scripts/ops/,tckdb_backup.shincluded. TCKDB_BOOTSTRAP_PASSWORDcan be removed from.env.db-adminafter the first start.TCKDB_API_PORT,TCKDB_WEB_PORT,DB_PORTandS3_PORTmove the loopback ports.TCKDB_HTTP_PORTandTCKDB_HTTPS_PORTmove Caddy's.- Uploads are processed inside the API by default. To run a separate upload
worker from the same image, set
TCKDB_INLINE_WORKER=falseand add--profile workerto theupcommand.
Next
- Which setup do I need?
- Production checklist before anyone else can reach it.
- Troubleshooting
- Operator runbooks on GitHub: migrations on a live database, monitoring, moving from MinIO to SeaweedFS, cutting a citable dataset release.