# Self-host Tianji

> An all-in-one insight hub that combines website analytics, uptime monitoring and server status in one dashboard.

- Page: https://levelrail.com/templates/tianji/
- JSON: https://levelrail.com/templates/tianji.json
- Category: Analytics
- Licence: Apache-2.0 (Permissive license)
- Source: https://github.com/msgbyte/tianji
- Upstream docs: https://tianji.dev/docs/intro

## Requirements
- Memory: about 512 MiB
- amd64: published, arm64: published
- Needs configuration before start: no
- Pinned image tag: 16-alpine

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| db | postgres | 16-alpine | none | pgdata -> /var/lib/postgresql/data |
| tianji | moonrailgun/tianji | 1.33.9 | 12345 | none |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| db | POSTGRES_DB | preset |
| db | POSTGRES_PASSWORD | generated |
| db | POSTGRES_USER | preset |
| tianji | ALLOW_OPENAPI | preset |
| tianji | ALLOW_REGISTER | preset |
| tianji | DATABASE_URL | generated |
| tianji | JWT_SECRET | generated |

## Deploy

### CLI

```bash
levelrail-cli templates install tianji --name my-tianji
```

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain db=app.example.com.

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  https://levelrail.example.com/api/v1/service-templates/tianji/install \
  -d '{
    "name": "my-tianji"
  }'
```

Create a token in the dashboard first. Name, env and domains are the request fields.

## Questions

### Can I deploy Tianji on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list has an entry with the id tianji for this app, so check that entry as well. Dokku deploys container images with its own commands, so the pinned image postgres:16-alpine, moonrailgun/tianji:1.33.9 is what you deploy there.

Self-host Tianji, Tianji docker compose file, deploy Tianji on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
