Release v2.0.4
This commit is contained in:
parent
3543a9b079
commit
08b7abbeea
@ -8,7 +8,7 @@
|
|||||||
# RELEASE VERSION
|
# RELEASE VERSION
|
||||||
# =====================================================
|
# =====================================================
|
||||||
# Tag fra Gitea (f.eks. v1.0.0, v1.2.3)
|
# Tag fra Gitea (f.eks. v1.0.0, v1.2.3)
|
||||||
RELEASE_VERSION=v2.0.3
|
RELEASE_VERSION=v2.0.4
|
||||||
|
|
||||||
# =====================================================
|
# =====================================================
|
||||||
# GITEA AUTHENTICATION
|
# GITEA AUTHENTICATION
|
||||||
|
|||||||
8
RELEASE_NOTES_v2.0.4.md
Normal file
8
RELEASE_NOTES_v2.0.4.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Release Notes v2.0.4
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
- Reworked the migration execution endpoint to stream SQL files via stdin instead of relying on chained shell commands, which broke on Podman/Docker setups and led to pattern-matching errors for some files.
|
||||||
|
- Added a default `CONTAINER_RUNTIME` setting so the endpoint knows whether to run `docker` or `podman` when the env var is not provided.
|
||||||
|
|
||||||
|
---
|
||||||
|
Release Date: 28. januar 2026
|
||||||
@ -147,6 +147,7 @@ class Settings(BaseSettings):
|
|||||||
POSTGRES_PASSWORD: str = "bmc_hub"
|
POSTGRES_PASSWORD: str = "bmc_hub"
|
||||||
POSTGRES_DB: str = "bmc_hub"
|
POSTGRES_DB: str = "bmc_hub"
|
||||||
POSTGRES_PORT: int = 5432
|
POSTGRES_PORT: int = 5432
|
||||||
|
CONTAINER_RUNTIME: str = "docker"
|
||||||
RELEASE_VERSION: str = "latest"
|
RELEASE_VERSION: str = "latest"
|
||||||
GITEA_URL: str = "https://g.bmcnetworks.dk"
|
GITEA_URL: str = "https://g.bmcnetworks.dk"
|
||||||
GITHUB_TOKEN: str = ""
|
GITHUB_TOKEN: str = ""
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from fastapi import APIRouter, Request, HTTPException
|
|||||||
from fastapi.responses import HTMLResponse
|
from fastapi.responses import HTMLResponse
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
import shlex
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
@ -65,15 +65,30 @@ def execute_migration(payload: MigrationExecution):
|
|||||||
raise HTTPException(status_code=404, detail="Migration file not found")
|
raise HTTPException(status_code=404, detail="Migration file not found")
|
||||||
|
|
||||||
# Determine the container runtime (Podman or Docker)
|
# Determine the container runtime (Podman or Docker)
|
||||||
container_runtime = "podman" if settings.CONTAINER_RUNTIME == "podman" else "docker"
|
runtime = settings.CONTAINER_RUNTIME.lower()
|
||||||
|
if runtime not in {"docker", "podman"}:
|
||||||
|
runtime = "docker"
|
||||||
|
|
||||||
# Execute the migration file
|
command = [
|
||||||
command = (
|
runtime,
|
||||||
f"cat {shlex.quote(str(migration_file))} | "
|
"exec",
|
||||||
f"{container_runtime} exec -i bmc-hub-postgres "
|
"-i",
|
||||||
f"psql -U {settings.POSTGRES_USER} -d {settings.POSTGRES_DB}"
|
"bmc-hub-postgres",
|
||||||
|
"psql",
|
||||||
|
"-U",
|
||||||
|
settings.POSTGRES_USER,
|
||||||
|
"-d",
|
||||||
|
settings.POSTGRES_DB,
|
||||||
|
]
|
||||||
|
|
||||||
|
migration_sql = migration_file.read_text()
|
||||||
|
result = subprocess.run(
|
||||||
|
command,
|
||||||
|
input=migration_sql,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
env={**os.environ, "PGPASSWORD": settings.POSTGRES_PASSWORD},
|
||||||
)
|
)
|
||||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
|
||||||
|
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise HTTPException(status_code=500, detail=f"Migration failed: {result.stderr}")
|
raise HTTPException(status_code=500, detail=f"Migration failed: {result.stderr}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user