A small Python API with a Dockerfile, a health check and tests, ready to deploy on LeafCloud.
All templates · Server apps with a Dockerfile
app/main.py: the API.GET /,GET /healthz,GET /items,GET /items/{id}, and interactive docs at/docs.Dockerfile: installs the exact versions fromuv.lock, runs as an unprivileged user, listens on$PORT(default 8080) on0.0.0.0.tests/: a few tests with FastAPI's test client.
Install uv, then:
git clone https://github.com/leafcloud-in/template-fastapi.git
cd template-fastapi
uv sync
uv run fastapi dev app/main.pyOpen http://127.0.0.1:8000/docs. Run the tests with uv run pytest.
To try the container the way LeafCloud runs it:
docker build -t template-fastapi .
docker run --rm -p 8080:8080 template-fastapi
curl http://127.0.0.1:8080/healthz- Choose Use this template on GitHub to make your own copy.
- In the LeafCloud dashboard, open Settings → GitHub, install the LeafCloud GitHub App on your account or organization, and pick your repository.
- LeafCloud finds the Dockerfile and opens a pull request that adds one workflow file. Merge it: every push to the branch builds the image in your GitHub Actions and deploys it.
Port: 8080. Health path: /healthz. Set your own environment variables and secrets in the app's settings.
Replace the sample ITEMS in app/main.py with your own routes and storage, add dependencies with
uv add <package>, and keep /healthz answering 200 so deploys can tell the app is up.
MIT