deploy.py: create_api_application ueber /applications/dockerfile (base64)
This commit is contained in:
+21
-6
@@ -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,
|
def create_api_application(client: CoolifyClient, project_uuid: str,
|
||||||
environment_name: str, server_uuid: str) -> str | None:
|
environment_name: str, server_uuid: str) -> str | None:
|
||||||
"""Create the API application from a Git repository.
|
"""Create the API application from the Dockerfile in the repo.
|
||||||
Returns the application UUID or None on failure."""
|
|
||||||
|
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:
|
try:
|
||||||
resp = httpx.post(
|
resp = httpx.post(
|
||||||
f"{client.base_url}/api/v1/applications",
|
f"{client.base_url}/api/v1/applications/dockerfile",
|
||||||
headers=client.headers,
|
headers=client.headers,
|
||||||
json={
|
json={
|
||||||
"project_uuid": project_uuid,
|
"project_uuid": project_uuid,
|
||||||
"environment_name": environment_name,
|
"environment_name": environment_name,
|
||||||
"server_uuid": server_uuid,
|
"server_uuid": server_uuid,
|
||||||
"git_repository": API_GIT_REPO,
|
|
||||||
"git_branch": API_GIT_BRANCH,
|
|
||||||
"build_pack": "dockerfile",
|
|
||||||
"name": "leocrm-api",
|
"name": "leocrm-api",
|
||||||
|
"dockerfile": dockerfile_b64,
|
||||||
|
"build_pack": "dockerfile",
|
||||||
},
|
},
|
||||||
timeout=30,
|
timeout=30,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user