step-ca-to-bookstack
Sync step-ca certificates to a BookStack page via step-badger; highlights expiry and runs on cron.
5.6K
This container reads your Smallstep step-ca Badger database with step-badger and automatically updates a BookStack page with a clear certificate list.
The container reads your data read-only. A temporary on‑disk copy avoids Badger DB lock errors while
step-cais running.
/pages/123).MANIFEST, KEYREGISTRY, *.sst, *.vlog). Example: host /docker/step/ca/db → container /step/db.Create or open docker-compose.yml and add this service:
services:
sync:
image: onesystems/step-ca-to-bookstack:latest
environment:
# When to sync? (cron, container local time)
CRON_SCHEDULE: "5 2 * * *" # daily 02:05
TZ: "Europe/Zurich"
# BookStack API
BOOKSTACK_URL: "https://wiki.example.com"
BOOKSTACK_PAGE_ID: "123" # your page ID
BOOKSTACK_TOKEN_ID: "<token-id>"
BOOKSTACK_TOKEN_SECRET: "<token-secret>"
# Alternative to the two lines above:
# BOOKSTACK_API_KEY: "<token-id>:<token-secret>"
# step-ca DB path inside the container
STEP_DB_DIR: "/step/db"
# (Optional) internal DB copy to avoid locks
DB_SNAPSHOT: "true"
TMP_BASE: "/tmp"
# (Optional) row colors / thresholds
WARN_DAYS: "30" # yellow when ≤ 30 days left
CRIT_DAYS: "10" # red when ≤ 10 days left
WARN_BG: "#fff6bf"
CRIT_BG: "#ffd6d6"
# (Optional) title above the tables (leave empty to hide)
TABLE_TITLE: "step-ca certificates"
volumes:
- /docker/step/ca:/step:ro # must contain directory "db"
restart: unless-stopped
Start the service:
docker compose up -d
Watch logs:
docker compose logs -f sync
On first start the page is updated immediately, then according to the schedule.
Days Left ≤ WARN_DAYSDays Left ≤ CRIT_DAYSIf the target page already contains the marker block, only the content between these markers is replaced on each run:
<!-- BEGIN STEP-CA TABLE --> ... (will be replaced) ... <!-- END STEP-CA TABLE -->
| Variable | Default | Description |
|---|---|---|
CRON_SCHEDULE | 0 3 * * * | Cron expression (container local time). |
BOOKSTACK_URL | — | Base URL, e.g. https://wiki.example.com. |
BOOKSTACK_PAGE_ID | — | Numeric ID of the page to update. |
BOOKSTACK_TOKEN_ID | — | BookStack API token ID. |
BOOKSTACK_TOKEN_SECRET | — | BookStack API token secret. |
BOOKSTACK_API_KEY | — | Alternative to the two vars above: id:secret. |
STEP_DB_DIR | /step/db | Path to step-ca Badger DB inside the container. |
DB_SNAPSHOT | true | If true, copy DB to a temp folder before reading (avoids lock). |
TMP_BASE | /tmp | Base folder for the temporary DB copy. Ensure enough space. |
TABLE_TITLE | step-ca certificates | Heading above the tables (set empty to hide). |
WARN_DAYS | 30 | Yellow when Days Left ≤ WARN_DAYS. |
CRIT_DAYS | 10 | Red when Days Left ≤ CRIT_DAYS. |
WARN_BG | #fff8d5 | CSS color for “warn” rows. |
CRIT_BG | #ffe5e5 | CSS color for “crit” rows. |
INCLUDE_EXPIRED | true | Kept for compatibility; not used (both tables are rendered). |
# Run the sync script inside the running container
docker exec -it <container> /usr/bin/python3 /app/sync.py
# Tail cron output
docker exec -it <container> sh -c 'tail -n 200 /var/log/cron.log'
“Cannot acquire directory lock … Another process is using this Badger database.”
This is expected while step-ca is running. Keep DB_SNAPSHOT=true and ensure there is free space under TMP_BASE (default /tmp).
Empty columns / missing values
JSON field names from step-badger may vary. The script uses a tolerant, deep lookup for common keys. If values remain empty, please verify that your mount contains the Badger files and check logs with docker compose logs -f sync.
BookStack 401/403
Double-check BOOKSTACK_URL, BOOKSTACK_PAGE_ID, and the token’s permissions. The token must be allowed to update the target page.
CRON_SCHEDULE (cron syntax)TABLE_TITLE to empty to hideWARN_DAYS, CRIT_DAYS, WARN_BG, CRIT_BGUpdate:
docker compose pull sync
docker compose up -d
Stop & remove:
docker compose down
.env file or Docker secrets, rather than hard-coding them in compose.Example
.env:BOOKSTACK_URL=https://wiki.example.com BOOKSTACK_PAGE_ID=123 BOOKSTACK_API_KEY=tokenid:tokensecretThen in
docker-compose.ymluseenv_file: [.env].
MIT License – free for commercial and private use.
Content type
Image
Digest
sha256:6585218f8…
Size
22.2 MB
Last updated
10 months ago
docker pull onesystems/step-ca-to-bookstack