deploy.py: create_api_application ueber /applications/private-deploy-key (Git-basiert)

This commit is contained in:
Agent Zero
2026-08-03 02:18:23 +02:00
parent 95972d2cdd
commit 236f0d2a5d
+15 -17
View File
@@ -806,35 +806,33 @@ 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 the Dockerfile in the repo.
"""Create the API application from a Git repository via private deploy key.
Uses POST /applications/private-deploy-key with the Coolify host's private key.
This creates a Git-based application that can auto-update on git push.
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()
# The private key UUID for the Coolify host (localhost)
PRIVATE_KEY_UUID = os.environ.get(
"COOLIFY_PRIVATE_KEY_UUID",
"rgcsc0048c04csckk8kogk40",
)
try:
resp = httpx.post(
f"{client.base_url}/api/v1/applications/dockerfile",
f"{client.base_url}/api/v1/applications/private-deploy-key",
headers=client.headers,
json={
"project_uuid": project_uuid,
"environment_name": environment_name,
"server_uuid": server_uuid,
"name": "leocrm-api",
"dockerfile": dockerfile_b64,
"private_key_uuid": PRIVATE_KEY_UUID,
"git_repository": API_GIT_REPO,
"git_branch": API_GIT_BRANCH,
"build_pack": "dockerfile",
"name": "leocrm-api",
"ports_exposes": "8000",
},
timeout=30,
)