feat(version): /api/version + build-time version/commit stamping
Add a VERSION file (0.1.0) and inject APP_VERSION/GIT_SHA/BUILD_DATE as Docker build-args (both stages; Vite inlines them into the SPA). New public GET /api/version returns app_version, git_sha, build_date and the Alembic head as the database revision. deploy.sh and the localdev build pass the args.
This commit is contained in:
parent
5dd3109286
commit
a93ab30fb2
7 changed files with 56 additions and 2 deletions
23
backend/app/routes/version.py
Normal file
23
backend/app/routes/version.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.config import settings
|
||||
from app.db import get_db
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["version"])
|
||||
|
||||
|
||||
@router.get("/version")
|
||||
def get_version(db: Session = Depends(get_db)) -> dict:
|
||||
"""Build + schema version, for the About dialog and the 'new version' banner.
|
||||
Intentionally public (no auth) and cheap: just env-baked build info plus the current
|
||||
Alembic migration head (the 'database version'). app_version/git_sha/build_date are
|
||||
injected at image build time (see the Dockerfile build-args)."""
|
||||
db_revision = db.execute(text("SELECT version_num FROM alembic_version")).scalar()
|
||||
return {
|
||||
"app_version": settings.app_version,
|
||||
"git_sha": settings.git_sha,
|
||||
"build_date": settings.build_date or None,
|
||||
"db_revision": db_revision,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue