deploy.py: create_api_application ueber /applications/dockerfile (base64)

This commit is contained in:
Agent Zero
2026-08-03 02:10:38 +02:00
parent cd48d99c65
commit 0c789f7660
+21 -6
View File
@@ -806,20 +806,35 @@ def set_service_envs(client: CoolifyClient, service_uuid: str, envs: list[dict])
def create_api_application(client: CoolifyClient, project_uuid: str,
environment_name: str, server_uuid: str) -> str | None:
"""Create the API application from a Git repository.
Returns the application UUID or None on failure."""
"""Create the API application from the Dockerfile in the repo.
Uses POST /applications/dockerfile with base64-encoded Dockerfile content.
Returns the application UUID or None on failure.
"""
import base64 as b64mod
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
dockerfile_path = os.path.join(repo_root, "Dockerfile")
try:
with open(dockerfile_path, "r") as f:
dockerfile_content = f.read()
except FileNotFoundError:
print(f" Error: Dockerfile not found at {dockerfile_path}")
return None
dockerfile_b64 = b64mod.b64encode(dockerfile_content.encode()).decode()
try:
resp = httpx.post(
f"{client.base_url}/api/v1/applications",
f"{client.base_url}/api/v1/applications/dockerfile",
headers=client.headers,
json={
"project_uuid": project_uuid,
"environment_name": environment_name,
"server_uuid": server_uuid,
"git_repository": API_GIT_REPO,
"git_branch": API_GIT_BRANCH,
"build_pack": "dockerfile",
"name": "leocrm-api",
"dockerfile": dockerfile_b64,
"build_pack": "dockerfile",
},
timeout=30,
)