Fix: Staging MEDIA_DIR=/prod-media direkt (kein Symlink-Umweg), SW by-v603
This commit is contained in:
parent
f76f3d7056
commit
c9e7e50bf4
4 changed files with 4 additions and 23 deletions
|
|
@ -48,7 +48,6 @@ async def lifespan(app: FastAPI):
|
|||
init_db()
|
||||
from routes.movies import seed_movies
|
||||
seed_movies()
|
||||
_link_prod_media()
|
||||
logger.info(f"KI-Modus: {ki.KI_MODE}")
|
||||
sched.start()
|
||||
yield
|
||||
|
|
@ -280,27 +279,10 @@ app.mount("/icons", StaticFiles(directory=f"{STATIC_DIR}/icons"), name="icons")
|
|||
app.mount("/img", StaticFiles(directory=f"{STATIC_DIR}/img"), name="img")
|
||||
|
||||
# User-generierte Medien (Fotos aus Tagebuch, Giftköder-Alarm, etc.)
|
||||
MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media")
|
||||
PROD_MEDIA_DIR = os.getenv("PROD_MEDIA_DIR", "") # Staging-only: Production-Media einlinken
|
||||
MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media")
|
||||
os.makedirs(MEDIA_DIR, exist_ok=True)
|
||||
app.mount("/media", StaticFiles(directory=MEDIA_DIR), name="media")
|
||||
|
||||
|
||||
def _link_prod_media():
|
||||
"""Staging: symlinkt Production-Media-Verzeichnisse in das Staging-Media-Verzeichnis."""
|
||||
if not PROD_MEDIA_DIR or not os.path.isdir(PROD_MEDIA_DIR):
|
||||
return
|
||||
import pathlib
|
||||
staging = pathlib.Path(MEDIA_DIR)
|
||||
for item in pathlib.Path(PROD_MEDIA_DIR).iterdir():
|
||||
link = staging / item.name
|
||||
if not link.exists() and not link.is_symlink():
|
||||
try:
|
||||
link.symlink_to(item)
|
||||
logger.info(f"Prod-Media verlinkt: {link} → {item}")
|
||||
except OSError as e:
|
||||
logger.warning(f"Symlink fehlgeschlagen {link}: {e}")
|
||||
|
||||
@app.get("/robots.txt")
|
||||
async def robots():
|
||||
return FileResponse(f"{STATIC_DIR}/robots.txt", media_type="text/plain")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '602'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '603'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.2.1'; // ← semantische Version, wird bei make release gesetzt
|
||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Offline-Cache + Push Notifications + Tile-Cache
|
||||
============================================================ */
|
||||
|
||||
const CACHE_VERSION = 'by-v602';
|
||||
const CACHE_VERSION = 'by-v603';
|
||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ services:
|
|||
- .env
|
||||
environment:
|
||||
- DB_PATH=/data/banyaro.db
|
||||
- MEDIA_DIR=/data/media
|
||||
- PROD_MEDIA_DIR=/prod-media
|
||||
- MEDIA_DIR=/prod-media
|
||||
- STAGING=true
|
||||
- VAPID_PUBLIC_KEY=BMKbFAmpsqJ-eFef_4XJcYpuxPWqBNAoy9buMNnMSa6ijcPzltboHi_YccPKJrUD0isBez-vJIzAgjnLTWkzcC0
|
||||
- VAPID_PRIVATE_KEY=8PWa9vvwMqtqsJEJGcwmiLhR0_Yl7duVX3wmWiKS878
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue