Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5.5 KiB
Deployment
Step-by-step for the backend (Docker + Traefik) and the Bromite userscript. Assumes you already run Traefik in Docker with a working HTTPS entrypoint and an ACME/cert resolver, and control a domain.
0. Prerequisites
- Docker + Docker Compose on the server.
- A Traefik instance watching a Docker network (default name assumed:
proxy). - DNS: an
A/AAAArecord formanga-api.<yourdomain>pointing at the server. - The repo copied to the server, e.g.
/opt/mangabm/(needsbackend/,docker-compose.yml,docker-compose.prod.yml,.env.example).
Confirm the Traefik network exists (create if not):
docker network ls | grep proxy || docker network create proxy
1. Configure .env
cd /opt/mangabm
cp .env.example .env
Edit .env:
# Required — long random secret, also goes in the userscript.
API_TOKEN=<paste output of: openssl rand -hex 32>
# CORS allowlist — leave as-is unless a site changes hostname.
ALLOWED_ORIGINS=https://asuracomic.net,https://asurascans.com,https://demonicscans.org
# Required for the Traefik override.
MANGA_API_HOST=manga-api.yourdomain.com
# Only if your Traefik setup differs from these defaults:
# PROXY_NETWORK=proxy
# TRAEFIK_ENTRYPOINT=websecure
# TRAEFIK_CERTRESOLVER=le
Generate + insert the token in one line:
sed -i "s|^API_TOKEN=.*|API_TOKEN=$(openssl rand -hex 32)|" .env
grep -E '^API_TOKEN=' .env # copy this — the userscript needs the same value
Match
TRAEFIK_ENTRYPOINT/TRAEFIK_CERTRESOLVERto your Traefik's actual names (check your Traefik static config — common alternatives:https,myresolver,cloudflare). Wrong names = no certificate issued.
2. Build + start
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
This merges the base file (build/image/env/volume) with the prod override
(no host port, Traefik network + router labels). Always pass both -f
flags — the prod file is not standalone.
Check it's up and healthy:
docker compose -f docker-compose.yml -f docker-compose.prod.yml ps
docker logs manga-api --tail 20 # expect: "listening on :8080 ..."
3. Verify over HTTPS
Give Traefik a few seconds to issue the cert, then:
# Health (no auth) — must be valid TLS, no cert warning.
curl -s https://manga-api.yourdomain.com/healthz # -> ok
# Auth enforced.
curl -s -o /dev/null -w '%{http_code}\n' \
https://manga-api.yourdomain.com/bookmarks # -> 401
TOKEN=$(grep -E '^API_TOKEN=' .env | cut -d= -f2)
curl -s -H "Authorization: Bearer $TOKEN" \
https://manga-api.yourdomain.com/bookmarks # -> []
# CORS preflight from a real site origin.
curl -s -i -X OPTIONS \
-H 'Origin: https://asurascans.com' \
-H 'Access-Control-Request-Method: PUT' \
https://manga-api.yourdomain.com/bookmarks/x | grep -i access-control
# -> Access-Control-Allow-Origin: https://asurascans.com (+ Methods/Headers)
All four must pass. Valid TLS is non-negotiable — the manga sites are HTTPS, so
a bad cert makes the browser block the userscript's fetch() (mixed content).
4. Configure the userscript
Edit the config block at the top of userscript/manga-bookmark.user.js:
const API_BASE = "https://manga-api.yourdomain.com"; // no trailing slash
const API_TOKEN = "<same token as .env>";
The token sits in the userscript's isolated world — the manga sites' JS can't read it.
5. Install on Bromite
- Bromite → Settings → User scripts → enable (accept the permission prompt).
- Put the edited
manga-bookmark.user.json the device (save the file, or open its raw URL). Bromite detects.user.jsand offers to install. - Confirm install — the
@matchlist covers both sites. - Open a series on asurascans.com or demonicscans.org → a 📑 button appears bottom-right → tap → + Bookmark this.
Optional desktop test: the script is GM_*-free, so the same file installs in
Tampermonkey/Violentmonkey for quick checks before going mobile.
6. Smoke-test the full loop
- Bookmark a series on Asura.
curl -s -H "Authorization: Bearer $TOKEN" https://manga-api.yourdomain.com/bookmarkson the server — the series should appear.- Open a chapter of that series — reopen the panel; last-read updates to that chapter (auto, never regresses on older chapters).
- Open Demonic, open the panel — the Asura bookmark shows there too (shared store, cross-site unified list).
Updating
Pull new code, then rebuild:
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
SQLite data persists in the named volume bookmarks-data across rebuilds.
Troubleshooting
| Symptom | Likely cause / fix |
|---|---|
| No cert / TLS error at the domain | TRAEFIK_ENTRYPOINT or TRAEFIK_CERTRESOLVER name wrong; or DNS not resolving yet. Check docker logs <traefik>. |
| 404 from Traefik | Service not on the proxy network, or MANGA_API_HOST mismatch. Confirm docker network inspect proxy lists manga-api. |
fetch fails in the userscript, curl works |
Origin missing from ALLOWED_ORIGINS, or mixed content (backend not HTTPS). |
| 401 with the right token | Trailing space/newline in API_TOKEN; regenerate and restart. |
| Panel button absent | URL didn't match an adapter, or user scripts disabled in Bromite. |
compose ... config errors about API_TOKEN |
Run compose from the dir with .env, or export the vars. |
Backend config reference and endpoint list: see README.md.