docker-compose.yml with Postgres and Alembic migrations, and deploy it to Reliant hosting with a managed Postgres. Forge reads the Dockerfile and the compose file and writes its declarations beside them; none of your Python changes. This guide was run on a minimal notes API at Forge v1.10.1-0.20261123064811-54313eead62f.
Before you begin
- Docker, and the app in a git repository with a root
Dockerfilethat builds on its own. - Forge:
reliant forgeinside Reliant, ornpx -y @reliantlabs/forge@latestanywhere else. - For a deploy that lasts, a Reliant account with app hosting billing. With no account you can still publish a 72-hour preview (step 6).
What the Dockerfile must do
Forge never builds your Python itself; a deploy runsdocker build on the Dockerfile and its context, nothing else. The detector reads the port from the compose service’s published port, else EXPOSE, else a --port in the start command, else ENV PORT, and sets PORT in the container. So listen on 0.0.0.0 and on $PORT:
Dockerfile
127.0.0.1, which nothing outside the container can reach: the probe fails and the rollout never becomes ready. Keep alembic and alembic.ini in the final image, because the migration job runs this same image. Add deploy, .forge and secrets to .dockerignore, so a deploy-config edit leaves the image digest alone.
Postgres and migrations
Read the database URL fromDATABASE_URL. Hosting injects a Postgres URL there. SQLAlchemy with psycopg 3 wants the postgresql+psycopg:// scheme, so rewrite postgres:// or postgresql:// to it in migrations/env.py and wherever you create the engine. The detector turns any of these into a migrate job that runs before every rollout: a compose service that migrates, or an alembic.ini. In the test app the compose file has one:
docker-compose.yml (excerpt)
service_completed_successfully: with a plain depends_on, forge env up dev treats the migration container’s exit as a failed service. Don’t run alembic upgrade inside the app’s startup as well: the job already ran it, and every replica racing to migrate is how half-migrated schemas happen.
1
Preview what Forge would write
terminal
Output (trimmed)
2
Adopt the app
terminal
forge.yaml and deploy/kcl/ and appends a block to .gitignore. Open deploy/kcl/workloads.k and read every # check: line. Each compose variable that looks like a credential (APP_SECRET: ${APP_SECRET} here) becomes a forge.ManagedSecret on staging and prod.3
Build, render and lint
terminal
Output (trimmed)
env render is the dry run of a deploy. Run it locally with reliant forge env up dev, which runs your compose file.4
Set secrets
The value is read from stdin, never from the command line:Then read the app the way the detector can’t:
terminal
os.environ.get("APP_SECRET", "dev") silently runs prod with the dev value if the secret is never delivered. Use os.environ["APP_SECRET"] so a missing secret fails at boot.5
Deploy
Signed in, to your organization:A hosted service and database need app hosting billing. Without it, the deploy is queued and exits 7 with the link to set billing up; nothing needs re-running afterwards. The default size is 250m CPU and 1 GiB of memory per workload.With no account, adopt with An unclaimed deploy is one service at 125m CPU and 128 MiB, its migration job and one Postgres of 256 MiB of data. It gets no secret values and no outbound internet until someone opens the claim link, so a FastAPI app that calls an outside API at startup won’t come up. It stays online for 72 hours. The test app idled at about 50 MiB under a 128 MiB limit with one uvicorn worker; each extra
terminal
--claimable instead, so prod fits the anonymous plan, preview it, then publish:terminal
--workers process adds roughly that again. Inside Reliant you are signed in, so --claimable is refused: drop it. Details: Deploy without an account.6
Verify
terminal
env status prints the URL. Hit an endpoint that reads and writes the database, not just /docs. Then branch on obs check’s exit code: 0 the release is proven good, 1 it regressed (run the suggested[] commands), 2 not proven, 8 the wait ran out before the after-window closed (check again later). Until the app sends OpenTelemetry traces it is exit 2, reason_code: no_request_telemetry: say “not proven good”, never “passed”. Send OpenTelemetry from any app fixes that (opentelemetry-instrumentation-fastapi).FastAPI gotchas
- Probe. The scaffold probes TCP. Serve a
/healthzand switch toprobes = tiers.Probes {readinessPath = "/healthz"}inworkloads.konce it checks the database. - Proxy headers. TLS ends at the hosting ingress. If you build absolute URLs or redirects, run uvicorn with
--proxy-headers --forwarded-allow-ips='*'sorequest.urlsayshttps. - Gunicorn.
gunicorn -k uvicorn.workers.UvicornWorker -b 0.0.0.0:$PORTworks the same; size workers to the memory you declare.
Troubleshooting
this content was refused by the platform's safety scan
this content was refused by the platform's safety scan
An unclaimed deploy’s image is scanned before it goes live, and the refusal (
reason: claimable_content_refused) doesn’t name what was found. It happened to our minimal Express test image; the release was built and recorded, but nothing was published. Deploy signed in instead, with reliant forge env deploy prod.has a Dockerfile and no Go module: an app in another language
has a Dockerfile and no Go module: an app in another language
You ran
project new --in-place without --kind app. Nothing was written.