feat:
--FREE docker-compose.yml --Fast API
This commit is contained in:
parent
8090c2e5ea
commit
bd6492564f
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@ venv/
|
||||
# Docker compose file
|
||||
compose_changes.json
|
||||
|
||||
docker-compose.yml
|
||||
# docker-compose.yml
|
||||
|
||||
# Python cache
|
||||
__pycache__/
|
||||
|
||||
25
docker-compose.yml
Normal file
25
docker-compose.yml
Normal file
@ -0,0 +1,25 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
mumble:
|
||||
build: .
|
||||
container_name: mumble_server
|
||||
restart: no
|
||||
ports:
|
||||
- 64738:64738/tcp
|
||||
- 64738:64738/udp
|
||||
- 6502:6502
|
||||
volumes:
|
||||
- ./data:/data
|
||||
- ./config/murmur.ini:/etc/mumble/murmur.ini
|
||||
environment:
|
||||
- MUMBLE_SUPERUSER_PASSWORD=pass
|
||||
- MUMBLE_CONFIG_ice="tcp -h 0.0.0.0 -p 6502"
|
||||
- MUMBLE_CONFIG_icesecretwrite=post Mod
|
||||
- MUMBLE_CONFIG_icesecretread=ice read
|
||||
- MUMBLE_CONFIG_dbDriver=db driver
|
||||
- MUMBLE_CONFIG_dbHost=172.16.10.3
|
||||
- MUMBLE_CONFIG_dbPort=5432
|
||||
- MUMBLE_CONFIG_database=dbnamepost
|
||||
- MUMBLE_CONFIG_dbUsername=dbusernamepost
|
||||
- MUMBLE_CONFIG_dbPassword=passwordpost
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
import re
|
||||
import json
|
||||
import os
|
||||
@ -8,6 +12,27 @@ JSON_FILE = "compose_changes.json"
|
||||
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
class ComposeConfig(BaseModel):
|
||||
icesecretwrite: Optional[str] = None
|
||||
icesecretread: Optional[str] = None
|
||||
dbDriver: Optional[str] = None
|
||||
dbHost: Optional[str] = None
|
||||
dbPort: Optional[str] = None
|
||||
database: Optional[str] = None
|
||||
dbUsername: Optional[str] = None
|
||||
dbPassword: Optional[str] = None
|
||||
|
||||
|
||||
|
||||
def read_json():
|
||||
if not os.path.exists(JSON_FILE):
|
||||
return {"file": "docker-compose.yml", "version": 0}
|
||||
@ -64,8 +89,30 @@ def update_compose(
|
||||
print(f"[✓] docker-compose.yml updated")
|
||||
|
||||
# --- usage ---
|
||||
update_compose(
|
||||
dbHost="172.test.test.test",
|
||||
dbPassword="testpassword",
|
||||
dbPort="5437test"
|
||||
)
|
||||
# update_compose(
|
||||
# dbHost="172.test.test.test",
|
||||
# dbPassword="testpassword",
|
||||
# dbPort="5437test"
|
||||
# )
|
||||
|
||||
@app.post("/update")
|
||||
def update(config: ComposeConfig):
|
||||
changes = config.model_dump()
|
||||
|
||||
# check at least one field provided
|
||||
if not any(v is not None for v in changes.values()):
|
||||
return {"error": "No fields provided — nothing to update"}
|
||||
print(changes)
|
||||
updated = update_compose(icesecretwrite=changes["icesecretwrite"],
|
||||
icesecretread=changes["icesecretread"],
|
||||
dbDriver=changes["dbDriver"],
|
||||
dbHost=changes["dbHost"],
|
||||
dbPort=changes["dbPort"],
|
||||
database=changes["database"],
|
||||
dbUsername=changes["dbUsername"],
|
||||
dbPassword=changes["dbPassword"])
|
||||
version = write_json(updated)
|
||||
|
||||
return {
|
||||
"message": "docker-compose.yml updated"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user