Implement automatic versioning and display in the application
- Added a step in the CI/CD pipeline to generate a version based on the branch and commit history. - Updated Dockerfile to accept the application version as an argument. - Modified the configuration to retrieve the application version from the environment variable. - Created a new API endpoint to expose the application version. - Added a new Svelte component to display the application version in the UI.
This commit is contained in:
@@ -77,10 +77,8 @@ async def http_exception_handler(request: Request, exc: HTTPException):
|
||||
|
||||
|
||||
def run_migrations():
|
||||
subprocess.run(
|
||||
["alembic", "upgrade", "head"],
|
||||
check=True
|
||||
)
|
||||
subprocess.run(["alembic", "upgrade", "head"], check=True)
|
||||
|
||||
|
||||
# Inicializar la base de datos
|
||||
@app.on_event("startup")
|
||||
@@ -132,3 +130,24 @@ async def root():
|
||||
async def health_check():
|
||||
"""Health check endpoint"""
|
||||
return {"status": "healthy", "environment": settings.ENVIRONMENT}
|
||||
|
||||
|
||||
@app.get("/api/version")
|
||||
async def get_version():
|
||||
"""
|
||||
Endpoint de versión de la aplicación
|
||||
|
||||
Retorna la versión de la aplicación que fue incrustada en la imagen Docker
|
||||
durante el proceso de CI/CD. La versión se genera automáticamente según la rama:
|
||||
- development: YY.MM.1.<short-git-hash>
|
||||
- main: YY.MM.0.<commit-count>
|
||||
|
||||
Returns:
|
||||
dict: Información de versión y entorno
|
||||
"""
|
||||
return {
|
||||
"service": settings.APP_NAME,
|
||||
"version": settings.APP_VERSION,
|
||||
"environment": settings.ENVIRONMENT,
|
||||
"debug": settings.DEBUG,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user