Install with Docker¶
JAI Tool ships as one Docker image, ghcr.io/dotapie/jaitool, with two ready-made Docker Compose examples.
This page takes you from an empty server to the setup wizard, and covers every setting, HTTPS, storage, logs, updates and the emergency commands.
Requirements¶
- Docker with the Compose plugin.
- An amd64 or arm64 machine: the image is built for both.
- PostgreSQL 18, either bundled with the app or a server you already run.
The database must be version 18 because the image's backup tools are PostgreSQL 18's.
pg_dump 18 refuses to back up a newer server, and restoring into an older one can fail.
If you use your own Postgres server, give JAI Tool:
- a database of its own, as a restore removes everything else in it;
- a user that owns that database, may create databases, and is never a superuser, as a restore runs a backup's SQL as this user;
- a user name and password of letters and digits only, as both go into the database address.
The first start adds the pg_trgm extension to the database, so the server must offer it.
Pick an example¶
Both examples are in the app repository under deploy-examples/prod/docker.
Each has a docker-compose.yml and a .env.example.
| Example | Use it when |
|---|---|
postgres-bundled |
You want Postgres to run next to the app, in its own container. Its data lives in the pgdata Docker volume. |
postgres-external |
You already have a Postgres 18 server. |
This is the app's service in the postgres-bundled example:
web:
image: ghcr.io/dotapie/jaitool:latest
env_file: .env
depends_on: [db]
volumes:
- ./storage/media:/app/storage/media # uploads
- ./storage/backups:/app/storage/backups # dumps
- ./certs:/app/certs:ro # fullchain.pem + privkey.pem, for HTTPS_ENABLED
ports:
- "8000:8000"
restart: unless-stopped
# Docker keeps logs forever by default: rotated at 10 MB, 20 files, 200 MB at most.
logging:
driver: json-file
options:
max-size: "10m"
max-file: "20"
The app listens on port 8000.
Uploads and backups go to storage/ next to docker-compose.yml, and HTTPS certificates to certs/.
In postgres-bundled, the database container creates the app's database user on its first start, with an empty volume.
That user is never a superuser, and the Postgres superuser keeps no password.
Install step by step¶
- Make a folder on the server and copy the example's
docker-compose.ymland.env.exampleinto it. - Rename
.env.exampleto.env. -
Generate the secrets:
docker run --rm ghcr.io/dotapie/jaitool keygenIt prints four lines, ready to paste over the
change-mevalues in.env:DATABASE_PASSWORD=... SETUP_TOKEN=... SECRET_KEY=... BACKUP_KEY=AGE-SECRET-KEY-1...With
postgres-external, skip theDATABASE_PASSWORDline, which that example does not use. -
Fill in the rest of
.env:PUBLIC_URL: the address people and phones open, with the port unless it is 80 or 443, such ashttp://192.168.1.20:8000.- With
postgres-bundled:DATABASE_USER, a name of letters and digits. - With
postgres-external:DATABASE_URL, the address of your database, such aspostgres://jaitool:secret@db.example.com:5432/jaitool. Inside the container,localhostis the container itself, not your server. - Copy
BACKUP_KEYto a safe place outside this server, such as a password manager. Without it, no backup can be opened. - Start JAI Tool:
docker compose up -d -
Open
PUBLIC_URLin a browser. The setup wizard asks forSETUP_TOKENand creates the first admin: continue with First-run setup.
The first start takes a moment while the database is prepared.
To watch it, run docker compose logs -f web.
The app refuses to start on a bad setting
If a value in .env still contains change-me, the log names it: Still change-me, replace it in .env: ....
The app also stops with a reason when SECRET_KEY or SETUP_TOKEN is too short, BACKUP_KEY is not an age key, PUBLIC_URL is not a full address, TRUSTED_PROXY is not an address or range, a storage backend is unknown, or HTTPS_ENABLED is on without its certificates.
Settings reference¶
Every setting lives in .env next to docker-compose.yml.
After you change one, run docker compose up -d again: it recreates the container with the new values.
Address and HTTPS¶
| Setting | What it does | Default | If you change it later |
|---|---|---|---|
PUBLIC_URL |
The address people and phones open, with the port unless it is 80 or 443, such as https://jaitool.example.com or http://192.168.1.20:8000. QR labels, emailed links and the phone sign-in QR code carry it. Required. An https:// address marks the sign-in cookies secure, so JAI Tool then works over HTTPS only. |
none | Labels printed before still scan in the phone app, but a phone's own camera app opens the old address. |
HTTPS_ENABLED |
true: the app serves HTTPS itself, on the same port, from certs/fullchain.pem and certs/privkey.pem. See HTTPS. |
false |
|
TRUSTED_PROXY |
Only behind a reverse proxy: its IP address or range, such as 172.16.0.0/12. Several are separated by commas. The app believes the forwarded visitor address and scheme only from these. |
empty | Left empty behind a proxy, every visitor looks like the proxy, so 5 wrong passwords lock that account for everyone. |
Database¶
| Setting | What it does | Default | If you change it later |
|---|---|---|---|
DATABASE_USER |
postgres-bundled only: the app's database user, made on the database's first start. Letters and digits only. |
none | The database keeps the user it made on the first start, so the app can no longer connect. |
DATABASE_PASSWORD |
postgres-bundled only: that user's password. Letters and digits only. |
none | As for DATABASE_USER. |
DATABASE_URL |
Where the database is: postgres://user:password@host:5432/database. In postgres-bundled it is built from the two settings above; leave that line as it is. |
none | The app uses the other database from then on. |
Secrets¶
| Setting | What it does | Default | If you change it later |
|---|---|---|---|
SETUP_TOKEN |
The password of the first-run setup wizard, 16 or more characters. Only the wizard asks for it. | none | You may remove it once setup is done. |
SECRET_KEY |
Signs sign-ins and emailed links, and encrypts the stored SMTP password and the two-factor keys. 48 or more characters. | none | Everyone is signed out, links already sent stop working, and the SMTP password and every two-factor setup are erased. |
BACKUP_KEY |
Every backup is encrypted with this age key. | none | Backups made before need the old key to restore or download. Backup & Restore re-encrypts them with the new key once you give it the old one. |
Keep BACKUP_KEY safe
Lose BACKUP_KEY and every backup made with it is gone, the ones copied off the server included.
Keep a copy outside this server, and give a replacement server the same key.
The .env.example also shows how to make a key with the age tools: apt install age, then age-keygen.
Changing SECRET_KEY
Change SECRET_KEY only if it leaked.
Afterwards, enter the SMTP password again in System settings.
Every user's two-factor setup is gone too: with two-factor authentication Required, everyone sets it up again at their next sign-in.
Storage¶
| Setting | What it does | Default | If you change it later |
|---|---|---|---|
MEDIA_STORAGE_BACKEND |
Where uploaded pictures and files go: local (the storage/media folder), s3 or azure. |
local |
Files already stored are not moved to the new place. |
BACKUP_STORAGE_BACKEND |
Where backups go: local (the storage/backups folder), s3 or azure. |
local |
As above. |
MEDIA_S3_BUCKET, BACKUP_S3_BUCKET |
The S3 bucket. | jaitool |
|
MEDIA_S3_ENDPOINT_URL, BACKUP_S3_ENDPOINT_URL |
The S3 service's address. Empty means Amazon S3. | empty | |
MEDIA_S3_REGION, BACKUP_S3_REGION |
The bucket's region. | empty | |
MEDIA_S3_ACCESS_KEY, BACKUP_S3_ACCESS_KEY, MEDIA_S3_SECRET_KEY, BACKUP_S3_SECRET_KEY |
The keys. They may stay empty where the platform grants access itself. | empty | |
MEDIA_AZURE_CONTAINER, BACKUP_AZURE_CONTAINER |
The Azure storage container. | jaitool |
|
MEDIA_AZURE_CONNECTION_STRING, BACKUP_AZURE_CONNECTION_STRING |
The connection string, from Access keys in the Azure portal. Required for azure. |
none | |
MEDIA_SENDFILE_HEADER, MEDIA_SENDFILE_PREFIX |
Let the reverse proxy send uploaded files. See Sendfile. | empty |
Logs and workers¶
| Setting | What it does | Default |
|---|---|---|
LOG_LEVEL |
How much the app logs: DEBUG, INFO, WARNING or ERROR. |
WARNING in the examples, INFO when removed |
GUNICORN_CMD_ARGS |
Extra flags for the web server (gunicorn), overriding its built-in ones, such as --access-logfile -. Built in: port 8000, 3 workers with 8 threads each. |
empty |
Dev section¶
These are for working on JAI Tool itself; keep them false on a real install.
| Setting | What it does | Default |
|---|---|---|
DEV_DJANGO_DEBUG |
Detailed error pages that show the code. Never on a real install. | false |
DEV_GUNICORN_ACCESS_LOG |
One log line per request. | false |
DEV_RELOAD_TEMPLATES |
Edited templates show without a restart. | false |
DEV_RELOAD_STATIC |
Edited CSS and JS show without a restart. | false |
Settings not in the examples¶
The app also reads these; add them to .env only if you need them.
| Setting | What it does | Default |
|---|---|---|
TIME_ZONE |
The time zone the setup wizard suggests, and the fallback when the time zone saved in System settings is unknown. | UTC |
LANGUAGE_CODE |
The fallback interface language, en or sk. |
en |
CSRF_TRUSTED_ORIGINS |
The addresses forms may be sent from, separated by commas. Setting it replaces the default, so include PUBLIC_URL. |
PUBLIC_URL |
BACKUP_TIMEOUT |
Seconds a database backup or restore may run before it is stopped. | 900 |
MAP_TILES |
false: location maps show no map background. |
true |
MAP_TILE_URL |
Where browsers load map tiles from. | https://tile.openstreetmap.org/{z}/{x}/{y}.png |
MAP_TILE_ATTRIBUTION |
The credit line shown on maps. | OpenStreetMap's |
MAP_TILE_REFERRER_POLICY |
The referrer policy for tile requests. OpenStreetMap refuses tiles without a referrer. | strict-origin-when-cross-origin |
MAP_GEOCODING |
false: the server no longer looks up addresses, so a location's map needs its latitude and longitude. |
true |
MAP_GEOCODER_URL |
The address lookup service. | https://nominatim.openstreetmap.org |
MAP_GEOCODER_AGENT |
The name the server gives the lookup service. Nominatim blocks generic names. | JAITool/<version> (internal inventory tool) |
MAP_GEOCODER_TIMEOUT |
Seconds to wait for an address lookup. | 4 |
GITHUB_REPO |
The GitHub repository the update check asks for the latest release. | DotaPie/jaitool |
STORAGE_ROOT |
The storage folder inside the container. Leave it: the examples' folders are mounted at the default. | /app/storage |
APP_VERSION is set by the image; do not set it yourself.
Connections to the internet
The update check asks GitHub for the latest release, and the location map asks Nominatim to look up addresses.
Browsers load map tiles from OpenStreetMap.
To keep JAI Tool off the internet, turn off Enable update check and Enable location maps in System settings, or set MAP_GEOCODING=false and MAP_TILES=false.
HTTPS¶
Phones need HTTPS for the camera scanner in the phone app. You have two ways to get it.
Built-in certificates¶
- Put your certificate as
fullchain.pemand its key asprivkey.pemin thecertsfolder next todocker-compose.yml. - In
.env, setHTTPS_ENABLED=trueand makePUBLIC_URLanhttps://address. With the examples' port mapping, it includes:8000. - Run
docker compose up -d.
# true: the app serves https itself from certs/fullchain.pem and certs/privkey.pem; to renew, replace both and
# run docker compose restart web. Phones need https for the camera scanner.
HTTPS_ENABLED=false
To renew the certificate, replace both files and run docker compose restart web.
If either file is missing or unreadable, the app does not start.
Behind a reverse proxy¶
Let your reverse proxy handle HTTPS and forward to port 8000, then:
- Set
PUBLIC_URLto thehttps://address the proxy serves. - Set
TRUSTED_PROXYto the proxy's IP address or range. - Leave
HTTPS_ENABLED=false, as the proxy speaks HTTPS to the browsers. - Make the proxy send the
X-Forwarded-ForandX-Forwarded-Protoheaders.
# Only behind a proxy: its IP address or range, such as 172.16.0.0/12. Left empty there, every visitor looks
# like the proxy, so 5 wrong passwords lock that account for everyone.
TRUSTED_PROXY=
JAI Tool believes those headers only from TRUSTED_PROXY, and takes the visitor's address from the last entry of X-Forwarded-For.
If visitors arrive over HTTPS while PUBLIC_URL still says http://, the app logs an error, as the sign-in cookies are then not marked secure.
Two proxy limits matter:
- Timeout. A backup or restore started in Backup & Restore runs within its request, for up to
BACKUP_TIMEOUT(15 minutes by default), so let the proxy wait that long. - Request size. Attachments can be up to 50 MB each and 20 at once, and an uploaded backup can be as big as your whole store, so let the proxy accept large uploads.
Where files are stored¶
By default everything stays on the server:
| What | Where |
|---|---|
| Uploaded pictures and files | storage/media |
Backups, encrypted with BACKUP_KEY |
storage/backups |
The database (postgres-bundled) |
the pgdata Docker volume |
| HTTPS certificates | certs |
You can keep uploads, backups, or both in S3-compatible storage or Azure Blob Storage instead. Each one picks its own backend, so you can keep uploads local and backups in a bucket.
# local (storage/), s3 or azure
MEDIA_STORAGE_BACKEND=local
BACKUP_STORAGE_BACKEND=local
# s3: the bucket must be PRIVATE. ENDPOINT_URL empty means Amazon; the keys may stay empty where the platform
# grants access itself.
# MEDIA_S3_BUCKET=jaitool
# MEDIA_S3_ENDPOINT_URL=
# MEDIA_S3_REGION=
# MEDIA_S3_ACCESS_KEY=
# MEDIA_S3_SECRET_KEY=
# BACKUP_S3_BUCKET=jaitool
# BACKUP_S3_ENDPOINT_URL=
# BACKUP_S3_REGION=
# BACKUP_S3_ACCESS_KEY=
# BACKUP_S3_SECRET_KEY=
# azure: the container must be PRIVATE. The connection string is under Access keys in the Azure portal.
# MEDIA_AZURE_CONTAINER=jaitool
# MEDIA_AZURE_CONNECTION_STRING=
# BACKUP_AZURE_CONTAINER=jaitool
# BACKUP_AZURE_CONNECTION_STRING=
- S3: remove the
#from the lines you need and fill them in. An empty endpoint means Amazon S3; with any other endpoint, such as a MinIO server, the app uses path-style addresses. - Azure: fill in the container and the connection string.
- In a bucket or container, uploads go under
media/and backups underbackups/, so both can share one bucket.
Keep the bucket private
The bucket or container must be private: a backup holds the whole database. JAI Tool checks each user's permission, then sends the browser to a signed link that works for one hour.
Changing a backend later does not move the files already stored.
Sendfile¶
With local uploads, the app sends every picture and file through its own web server. Behind nginx, Caddy, Apache or lighttpd, you can let the proxy send them instead and keep the app's workers free:
# Let proxy send file instead of gunicorn worker. Requires also proper proxy configuration.
# > nginx/Caddy: X-Accel-Redirect
# > Apache/lighttpd: X-Sendfile
# Traefik, HAProxy, Envoy, Cloudflare and cloud load balancers are not supported.
# MEDIA_SENDFILE_HEADER=X-Accel-Redirect
# MEDIA_SENDFILE_PREFIX=/protected-media/
MEDIA_SENDFILE_HEADER:X-Accel-Redirectfor nginx and Caddy,X-Sendfilefor Apache and lighttpd.MEDIA_SENDFILE_PREFIX: the path the app puts before the file's name, such as/protected-media/.
The app still checks the user's permission, then answers with that header, naming the prefix followed by the file's path.
Your proxy must map the prefix to the media folder (storage/media) and be able to read it.
It works only with MEDIA_STORAGE_BACKEND=local.
Warning
Make the prefix reachable only through the header, such as an internal location in nginx.
Otherwise anyone who knows a file's path can open it without signing in.
Logs and health¶
Read the app's log with:
docker compose logs -f web
The examples keep at most 20 log files of 10 MB each.
LOG_LEVEL sets how much is written; for one line per request, set DEV_GUNICORN_ACCESS_LOG=true or GUNICORN_CMD_ARGS=--access-logfile -.
Docker checks the app's health every 30 seconds; docker compose ps shows it as healthy or unhealthy.
The first 120 seconds after a start do not count, to leave time for the backup and migrations.
Automatic backups, automatic cleanup and the summary email run inside the web container, so they only happen while it runs. If they stop, admins see a Scheduler card on the Overview.
Updating¶
To update to the newest release:
docker compose pull
docker compose up -d
The examples use the latest tag.
To stay on one release, change latest in docker-compose.yml to a version, such as ghcr.io/dotapie/jaitool:0.9.0.
With Enable update check on, admins see Update available on the Overview when a newer release is out.
Every time the container starts, it does this before the app opens:
- Waits for the database, for up to 60 seconds; then the container stops, and Docker starts it again.
- Backs up first, if the update brings database changes. The backup shows as Before DB migration in Backup & Restore, and only the newest one of that kind is kept. If this backup fails, the container stops and nothing is changed.
- Applies the database changes (migrations).
- Makes sure a default location exists. If System settings has no location for new items, it picks or creates one named "Default warehouse".
- Prepares the app's files and translations, then starts the web server.
On a large database the backup and migrations can take minutes; follow them with docker compose logs -f web.
Note
A backup made by a newer JAI Tool cannot be restored by an older one.
Emergency commands¶
These commands help when you cannot fix things from the app's own pages.
Run them in the folder that holds docker-compose.yml.
List and restore backups¶
List the backups, newest first:
docker compose run --rm --entrypoint python web src/manage.py backups --list
--entrypoint python skips the start-up steps above, which can fail against a database from another version.
The list shows each backup's NAME, TAKEN (in the System settings time zone), KIND, SIZE, CREATED BY and NOTE.
NOTE holds the backup's own note, or one of these warnings:
| Note | Meaning |
|---|---|
UNREADABLE, cannot be restored |
The file cannot be read, or its backup format does not match this version. |
NEWER VERSION, cannot be restored here |
A newer JAI Tool made it; update first. |
ANOTHER KEY, restoring asks for it |
It was made with an earlier BACKUP_KEY. |
Restore one by the name the list shows:
docker compose run --rm --entrypoint python web src/manage.py backups --restore jaitool-20261204-030000-123.jtbak
- Type
yesto confirm. - If the backup was made with an earlier
BACKUP_KEY, type that key; it is not shown as you type.
Warning
A restore replaces the whole database and every uploaded file with the backup's. Before it starts, JAI Tool saves the current state as a new backup and prints its name, so you can go back.
When the backup comes from an older version, the database changes are applied after the restore.
--noinput restores without asking, but cannot restore a backup that needs an earlier key.
For everything else about backups, see Backup & Restore.
Reset two-factor sign-in¶
If an admin loses the phone with their authenticator app and no other admin can help, reset their two-factor sign-in:
docker compose exec web python src/manage.py reset_2fa admin@example.com
It removes the account's two-factor setup and signs it out everywhere, like Remove 2FA on the user's Actions tab in User management. If two-factor authentication is Required, the next sign-in sets it up again; see Signing in.
Next step¶
Open PUBLIC_URL and go through the First-run setup.