Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 2.47 KB

README.md

File metadata and controls

46 lines (29 loc) · 2.47 KB

One Python backend on your machine

This example is one authored service.json and one small FastAPI service on Python 3.12. Flisk creates the local orchestration files; Docker builds the service and Tilt runs it. Live reload does not work yet: every edit rebuilds the image (see Live reload). No Kubernetes cluster is needed, and you do not need Bun, Node.js, or Python installed on your machine for the service itself.

It is the Python counterpart of the one-backend example. The source in services/one-backend-python/api is exactly what this command generates:

flisk resource api-backend --type backend --language python --stack one-backend-python

Prerequisites

Install Docker (Desktop, OrbStack, or Colima), Tilt 0.25.0 or newer, and the Flisk CLI. Ports 80, 443, and 5432 must be available.

From the repository root:

cd examples/one-backend-python
flisk project --yes
flisk up one-backend-python

The service is routed at http://api.one-backend-python.localhost/api/api-backend. If port 80 is busy, Flisk picks another host port; flisk doctor --json reports it. Check it with:

curl --fail http://api.one-backend-python.localhost/api/api-backend/health
# {"status":"ok","service":"api-backend"}

Open the Tilt dashboard at http://localhost:10350. Stop the local stack with flisk down.

Live reload

Edit services/one-backend-python/api/src/main.py and Tilt picks the change up. Today every edit, including to main.py, triggers a full image rebuild instead of a file sync (Tilt reports Found file(s) not matching any sync), so expect a few seconds of rebuild per change. This is a known engine issue, tracked in openspec/changes/add-python-backend-provider/tasks.md task 4.5, and is not specific to Python. Changing pyproject.toml rebuilds the image to install the new dependencies, which is the intended behavior.

Run the tests

The generated image has a test stage that runs pytest, so no local Python is needed. The image Dockerfile is generated by Flisk, so run flisk up one-backend-python once first (flisk project --yes alone does not write it). Then build the test stage from the example directory, which is the build context:

docker build --target test -f services/one-backend-python/api/.autogenerated/Dockerfile.app.autogenerated .

More

See the backend provider guide. For a language without a provider, use --type bring-your-own.