forked from xhgit/webup-cloud
Publish AI workspace source through the isolated runtime
This commit is contained in:
1 parent
03169bd0f6
commit
d1d14f0f77
21 files changed
+487
-68
No files matched your search
@@ -3,6 +3,12 @@ set -euo pipefail
|
||||
[[ ${WSL_DISTRO_NAME:-} == WebUp-Local && $EUID == 0 && -e /etc/webup-local/environment ]] || { echo 'Dedicated local environment required.' >&2; exit 1; }
|
||||
project_root=$(realpath "$1")
|
||||
k3s kubectl apply -f "$project_root/infra/k8s/review-rbac.yaml"
|
||||
k3s kubectl apply -f "$project_root/infra/k8s/runtime-rbac.yaml"
|
||||
if k3s kubectl -n platform-sandboxes get configmap webup-runtime >/dev/null 2>&1; then
|
||||
k3s kubectl -n platform-sandboxes patch configmap webup-runtime --type merge -p '{"data":{"SOURCE_IMAGE":"docker.io/library/webup-development-sandbox:local-v1"}}'
|
||||
else
|
||||
k3s kubectl -n platform-sandboxes create configmap webup-runtime --from-literal=SOURCE_IMAGE=docker.io/library/webup-development-sandbox:local-v1
|
||||
fi
|
||||
install -d -m 0700 /etc/webup-local
|
||||
if [[ ! -e /etc/webup-local/gateway.env ]]; then
|
||||
python3 - <<'PY'
|
||||
@@ -40,6 +46,7 @@ WantedBy=multi-user.target
|
||||
UNIT
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now webup-gateway-forward
|
||||
systemctl restart webup-gateway-forward
|
||||
install -d -m 0700 "$project_root/.runtime/local-cluster"
|
||||
cp /etc/webup-local/gateway.env "$project_root/.runtime/local-cluster/gateway.env"
|
||||
python3 - <<'PY'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
param([switch]$EnableHosting)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$projectRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../..'))
|
||||
$localDirectory = Join-Path $projectRoot '.runtime/local-cluster'
|
||||
@@ -27,11 +28,15 @@ foreach ($key in @('SANDBOX_TOKEN', 'RUNTIME_TOKEN')) {
|
||||
}
|
||||
$health = Invoke-RestMethod -Uri http://127.0.0.1:8090/health/ready -Headers @{Authorization = ('Bearer ' + $gatewayValues['SANDBOX_TOKEN'])} -TimeoutSec 10
|
||||
if (-not $health.ready) { throw 'Gateway Kubernetes readiness check failed.' }
|
||||
if ($EnableHosting) {
|
||||
$runtime = Invoke-RestMethod -Uri http://127.0.0.1:8090/runtime/source-ready -Headers @{Authorization = ('Bearer ' + $gatewayValues['RUNTIME_TOKEN'])} -TimeoutSec 10
|
||||
if (-not $runtime.ready) { throw 'Local source runtime is not configured. Deploy the updated gateway first.' }
|
||||
}
|
||||
$infra = @{app = @{
|
||||
'worker-enabled' = $true; 'worker-capacity' = 4
|
||||
'sandbox-url' = 'http://127.0.0.1:8090'; 'sandbox-token' = $gatewayValues['SANDBOX_TOKEN']
|
||||
'runtime-url' = 'http://127.0.0.1:8090'; 'runtime-token' = $gatewayValues['RUNTIME_TOKEN']
|
||||
'runtime-worker-enabled' = $false
|
||||
'runtime-worker-enabled' = [bool]$EnableHosting
|
||||
}}
|
||||
$infra | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath (Join-Path $localDirectory 'preview-infrastructure.yml') -Encoding utf8
|
||||
Set-Content -LiteralPath $triggerFile -Value (Get-Date -Format o)
|
||||
|
||||
Reference in new issue
Block a user