Scaffold FastAPI app with health endpoint, Dockerfile, and Woodpecker CI #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lineage
plan-mcd-tracker→ Phase 2: Backend Scaffold + First DeployRepo
forgejo_admin/mcd-tracker-apiUser Story
As a platform operator
I want a FastAPI skeleton deployed to production via the full CI/CD pipeline
So that the mcd-tracker-api is live, healthy, and ready for feature development.
Architecture
arch-deployment-mcd-tracker— this populates the API pod. The full pipeline runs: push → Woodpecker (test + build) → Harbor → ArgoCD Image Updater → deploy.arch-dataflow-mcd-tracker— health endpoint is the first trivial runtime flow.Context
Phase 1 completed: namespace
mcd-trackerexists, Harbor project ready, ArgoCD app created, Tailscale funnel live. Pod is in ImagePullBackOff because no image exists yet. This phase creates the app, pushes the first image, and resolves the ImagePullBackOff.Follow the basketball-api pattern at
~/basketball-api/for project structure, Dockerfile, and .woodpecker.yaml.File Targets
Files to create:
src/mcd_tracker_api/__init__.py— emptysrc/mcd_tracker_api/main.py— FastAPI app with lifespan context managersrc/mcd_tracker_api/config.py— Pydantic BaseSettings withMCD_TRACKER_env prefix,database_urlfieldsrc/mcd_tracker_api/routes/__init__.py— emptysrc/mcd_tracker_api/routes/health.py—/healthzendpoint returning{"status": "ok"}pyproject.toml— project metadata, dependencies (fastapi, uvicorn, pydantic-settings), ruff configDockerfile— multi-stage build (builder installs deps, runtime copies and runs uvicorn on port 8000).woodpecker.yaml— two steps:test(ruff check + ruff format --check) andbuild-and-push(kaniko to Harbor)tests/__init__.py— emptytests/test_health.py— basic health endpoint testFiles NOT to touch:
Acceptance Criteria
uvicorn mcd_tracker_api.main:appstarts locallycurl localhost:8000/healthzreturns{"status": "ok"}ruff check src/passesruff format --check src/passespytest tests/passes.woodpecker.yamlhas test + build-and-push steps${CI_COMMIT_SHA}(NOT$CI_COMMIT_SHA— must use braces for Woodpecker kaniko plugin)Test Expectations
pytest tests/test_health.py— health endpoint returns 200 with{"status": "ok"}pytest tests/ -vConstraints
src/mcd_tracker_api/(NOTapp/)MCD_TRACKER_env prefix (Pydantic Settingsmodel_config = {"env_prefix": "MCD_TRACKER_"})${CI_COMMIT_SHA}with braces — Woodpecker doesn't expand$CI_COMMIT_SHAwithout themharbor.tail5b443a.ts.net/mcd-tracker/apiharbor_usernameandharbor_passwordChecklist
curl https://mcd-tracker.tail5b443a.ts.net/healthzreturns 200Related
project-mcd-tracker— project pagephase-mcd-tracker-2-backend-scaffold— phase notearch-deployment-mcd-tracker— deployment diagramScaffold Complete
All acceptance criteria met:
fc1edad) + k8s env collision fix (e596e33)harbor_username+harbor_passwordcurl https://mcd-tracker.tail5b443a.ts.net/healthzreturns{"status":"ok"}(HTTP 200)Files Created
src/mcd_tracker_api/__init__.pysrc/mcd_tracker_api/main.py-- FastAPI app with lifespansrc/mcd_tracker_api/config.py-- Pydantic Settings,MCD_TRACKER_prefixsrc/mcd_tracker_api/routes/__init__.pysrc/mcd_tracker_api/routes/health.py--/healthz+/metricspyproject.toml-- hatchling, fastapi, uvicorn, pydantic-settings, ruffDockerfile-- multi-stage build, port 8000.woodpecker.yaml-- test (ruff + pytest) + build-and-push (kaniko).gitignoretests/__init__.pytests/test_health.py-- 2 tests passingBug Found and Fixed
Kubernetes injects
MCD_TRACKER_PORT=tcp://10.43.x.x:8000for service discovery, which collides with the Pydanticport: intfield. Renamed toserver_host/server_portto avoid the collision.