canonical / canonical/api_demo_server
Support the 12-factor FastAPI framework for charms
- Dominant language
- Python
- Stars
- 4
- Forks
- 5
- Avg merge
- 3h 25m
- Merged PRs (30d)
- 3
Description
After #45, we should consider whether the rock should support Charmcraft's 12-factor FastAPI framework. It would be nice to use the rock to demonstrate the benefits of the framework when developing a charm.
To support the framework, at minimum we'd need to:
- Call the Pebble service `fastapi` - we can do this in [#45](https://github.com/canonical/api_demo_server/pull/45).
- Rename environment variables from `DEMO_SERVER_DB_*` to `POSTGRESQL_DB_*`.
- Instead of hardcoding the database name, use `os.environ.get("POSTGRESQL_DB_NAME", "names_db")`. The framework sets `POSTGRESQL_DB_NAME` based on the app name.
See https://documentation.ubuntu.com/charmcraft/4.3/reference/extensions/fastapi-framework-extension/
The changes would have downstream impact - primarily the [Kubernetes charm tutorial in Ops](https://canonical.com/juju/docs/ops/latest/tutorial/from-zero-to-hero-write-your-first-kubernetes-charm/).
Contributor guide
Research direction
Start by reviewing PR #45 and the Charmcraft 12-factor FastAPI framework extension documentation. Locate the Pebble service name, DEMO_SERVER_DB_* variables, and hardcoded database name in the repository, then verify that the renamed configuration supports the framework and does not break the downstream Kubernetes charm tutorial.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- backend, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100