ci: dockerise l'API + connexion DB et CORS configurables par env

- config.py: connexion SQL via DB_* (driver 18, auth SQL), fallback Windows local
- main.py: origines CORS via CORS_ORIGINS
- Dockerfile (python 3.12 + msodbcsql18) + workflow Gitea Actions (build/push image)
This commit is contained in:
neckfire
2026-06-20 12:21:47 +02:00
parent e0b314ee76
commit 51d041c0da
4 changed files with 97 additions and 7 deletions
+11 -1
View File
@@ -7,6 +7,8 @@
# Swagger : http://localhost:8000/docs
# ============================================================
import os
from fastapi import FastAPI, HTTPException, Query
from fastapi.middleware.cors import CORSMiddleware
from typing import Optional
@@ -14,6 +16,14 @@ from datetime import date
from config import Config, get_cursor
# Origines autorisées : depuis CORS_ORIGINS (séparées par des virgules) en prod,
# localhost par défaut en dev.
CORS_ORIGINS = [
o.strip()
for o in os.getenv("CORS_ORIGINS", "http://localhost:5173,http://localhost:3000").split(",")
if o.strip()
]
# ============================================================
# Initialisation
# ============================================================
@@ -26,7 +36,7 @@ app = FastAPI(
app.add_middleware(
CORSMiddleware,
allow_origins = ["http://localhost:5173", "http://localhost:3000"],
allow_origins = CORS_ORIGINS,
allow_methods = ["GET"],
allow_headers = ["*"],
)