Update
DevPlace CI / test (push) Has been cancelled

This commit is contained in:
2026-08-10 00:23:20 +02:00
parent 2bdcf6528f
commit 6cac64a3f6
63 changed files with 3499 additions and 68 deletions
+25 -21
View File
@@ -443,7 +443,7 @@ def pravda_env(instance: dict) -> dict:
def workspace_env(instance: dict, base_url: str) -> dict:
from devplacepy import database
from devplacepy.database import get_setting
from devplacepy.services.containers.workspace import naming, quota
from devplacepy.services.containers.workspace import editor, naming, quota
if not instance.get("is_workspace"):
return {"DEVPLACE_WORKSPACE": ""}
@@ -476,9 +476,12 @@ def workspace_env(instance: dict, base_url: str) -> dict:
gallery = get_setting("workspace_extensions_gallery", "").strip()
editor_port = int(instance.get("editor_port") or 0)
profile = editor.resolve(owner_uid, instance)
env = {
"DEVPLACE_WORKSPACE": "1",
"DEVPLACE_WORKSPACE_UID": instance.get("uid") or "",
"DEVPLACE_CONTAINER_BOOT": instance.get("boot_marker") or "",
**editor.env_for(profile),
"DEVPLACE_WORKSPACE_URL": workspace_url,
"DEVPLACE_WORKSPACE_OWNER": owner_name,
"DEVPLACE_WORKSPACE_OWNER_UID": owner_uid,
@@ -546,27 +549,28 @@ def ensure_editor_password(instance: dict) -> str:
return password
def editor_command(instance: dict) -> list[str]:
port = int(instance.get("editor_port") or EDITOR_DEFAULT_PORT)
return [
"code-server",
"--bind-addr",
f"0.0.0.0:{port}",
"--auth",
"password",
"--disable-telemetry",
"--disable-update-check",
"--user-data-dir",
f"{WORKSPACE_STATE_MOUNT}/data",
"--extensions-dir",
f"{WORKSPACE_STATE_MOUNT}/extensions",
WORKSPACE_MOUNT,
]
def stamp_boot_marker(instance: dict) -> str:
from devplacepy.utils import generate_uid
marker = generate_uid()
store.update_instance(instance["uid"], {"boot_marker": marker})
instance["boot_marker"] = marker
return marker
def run_spec_for(instance: dict, image_tag: str) -> RunSpec:
from devplacepy.services.containers.workspace import editor
profile = None
cpu_limit = instance.get("cpu_limit", "")
mem_limit = instance.get("mem_limit", "")
if instance.get("is_workspace"):
ensure_editor_password(instance)
stamp_boot_marker(instance)
profile = editor.resolve(instance.get("workspace_owner_uid", ""), instance)
editor.seed_state(instance, profile)
cpu_limit = profile.cpu_limit() or cpu_limit
mem_limit = profile.mem_limit() or mem_limit
env = {**json.loads(instance.get("env_json") or "{}"), **pravda_env(instance)}
ports = [
PortMapping(p["host"], p["container"], p.get("proto", "tcp"))
@@ -584,8 +588,8 @@ def run_spec_for(instance: dict, image_tag: str) -> RunSpec:
)
language = (instance.get("boot_language") or "none").strip().lower()
boot = (instance.get("boot_command") or "").strip()
if instance.get("is_workspace") and int(instance.get("editor_port") or 0):
command = editor_command(instance)
if profile and int(instance.get("editor_port") or 0):
command = editor.argv(instance, profile)
elif language in BOOT_SCRIPT_FILES and (instance.get("boot_script") or "").strip():
script_path = f"{WORKSPACE_MOUNT}/{BOOT_SCRIPT_FILES[language]}"
command = [BOOT_SCRIPT_RUNNERS[language], script_path]
@@ -601,8 +605,8 @@ def run_spec_for(instance: dict, image_tag: str) -> RunSpec:
PROJECT_LABEL: instance["project_uid"],
},
env=env,
cpu_limit=instance.get("cpu_limit", ""),
mem_limit=instance.get("mem_limit", ""),
cpu_limit=cpu_limit,
mem_limit=mem_limit,
ports=ports,
mounts=mounts,
restart_policy=instance.get("restart_policy", "never"),