Repository navigation
Hosting It
Running it locally for yourself needs nothing. Putting it where colleagues can use it changes four things.
export BRANDKIT_SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))")Without it an ephemeral key is generated at startup, and the consequences are exactly the sort that waste an afternoon:
- Sessions break on every restart, so users are interrupted whenever you deploy
- With more than one gunicorn worker, the workers reject each other's CSRF tokens, which presents as a form that fails at random depending on which worker answered
FLASK_SECRET_KEY is accepted as an alias. This is the single most important environment variable and it has no safe default by design.
Uploads land in static/uploads/ and a periodic sweep removes them:
BRANDKIT_CLEANUP_ENABLED=true # default
BRANDKIT_CLEANUP_INTERVAL_HOURS=1 # how often the sweep runs
BRANDKIT_RETENTION_HOURS=24 # how old before deletionThe defaults are sensible. What matters is that you know the number, because on a shared instance those are other people's unreleased logos and product shots sitting on your disk for a day. Shorten it if that matters, and never disable the sweep on a shared deployment: without it the directory grows without bound and nothing is ever deleted.
BRANDKIT_MAX_UPLOAD_MB=16 # defaultRaise it only if you need to. A larger limit means a larger image held in memory through the whole processing chain, per concurrent request.
Background removal is the memory-heavy part. rembg loads an ONNX neural model, so a container doing background removal wants meaningfully more RAM than one doing plain resizing. If the container is being killed under load, that is where to look before anything else.
The model is also downloaded on first use, from GitHub. On an air-gapped host, pre-seed ~/.u2net/ or background removal simply will not work.
The README says it: do not expose the Flask development server. Nginx or Caddy for TLS termination, and a tunnel such as Cloudflared if you want access control rather than an open URL.
Rate limiting is already there, 200 requests a day and 50 an hour by default, along with CSRF protection, a Content Security Policy and security headers through Talisman. That is a good baseline, and it is per-IP: a whole office behind one address shares the allowance, so raise it or exempt your network if colleagues start hitting the limit.
There is no authentication. Anyone who reaches the URL can upload an image and generate assets, and there is no per-user separation of uploads. On a private network that is fine. On the open internet it is an unauthenticated image-processing endpoint, which is both a resource-abuse target and a place where strangers' images end up on your disk.
If it needs to be reachable from outside, put authentication in front of it.
Nothing about the images leaves the machine: processing is Pillow, NumPy and ONNX Runtime, in-process. Since v1.1.3 Tailwind and Alpine are vendored and served from your own origin, so loading the page makes no third-party requests either. On v1.1.2 or earlier they came from CDNs, which disclosed the visitor's IP and the fact of the visit: that alone is a reason to upgrade a hosted instance.
Metadata stripping is available and worth enabling on a shared instance, since an uploaded photograph can carry GPS coordinates and a camera serial number into the generated output.
BrandKit · Documentation · Issues · MIT · Self-hosted: your images stay on your machine
In this wiki
Reference
Project