fix(ci): reuse provider egress for backend-core artifacts

This commit is contained in:
Codex
2026-05-19 01:02:17 +00:00
parent 29dab8fab2
commit 49cf1e57bb
7 changed files with 408 additions and 256 deletions
@@ -276,6 +276,8 @@ spec:
- name: registry
type: string
default: 127.0.0.1:5000
- name: source-host-path
type: string
workspaces:
- name: source
volumes:
@@ -283,26 +285,17 @@ spec:
hostPath:
path: /var/run/docker.sock
type: Socket
- name: prepared-source
hostPath:
path: /home/ubuntu/.unidesk/ci/backend-core-artifacts
type: Directory
steps:
- name: clone
- name: prepare-source
image: alpine/git:2.45.2
env:
- name: HTTP_PROXY
value: "http://d601-provider-egress-proxy.unidesk.svc.cluster.local:18789"
- name: HTTPS_PROXY
value: "http://d601-provider-egress-proxy.unidesk.svc.cluster.local:18789"
- name: ALL_PROXY
value: "http://d601-provider-egress-proxy.unidesk.svc.cluster.local:18789"
- name: NO_PROXY
value: "localhost,127.0.0.1,::1,host.docker.internal,d601-provider-egress-proxy,d601-provider-egress-proxy.unidesk,d601-provider-egress-proxy.unidesk.svc,d601-provider-egress-proxy.unidesk.svc.cluster.local"
- name: http_proxy
value: "http://d601-provider-egress-proxy.unidesk.svc.cluster.local:18789"
- name: https_proxy
value: "http://d601-provider-egress-proxy.unidesk.svc.cluster.local:18789"
- name: all_proxy
value: "http://d601-provider-egress-proxy.unidesk.svc.cluster.local:18789"
- name: no_proxy
value: "localhost,127.0.0.1,::1,host.docker.internal,d601-provider-egress-proxy,d601-provider-egress-proxy.unidesk,d601-provider-egress-proxy.unidesk.svc,d601-provider-egress-proxy.unidesk.svc.cluster.local"
volumeMounts:
- name: prepared-source
mountPath: /prepared-source
readOnly: true
script: |
#!/bin/sh
set -eu
@@ -310,16 +303,22 @@ spec:
[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ;;
*) echo "backend_core_artifact_revision_must_be_full_sha=$(params.revision)" >&2; exit 2 ;;
esac
rm -rf "$(workspaces.source.path)/backend-core-artifact-repo"
git clone --filter=blob:none "$(params.repo-url)" "$(workspaces.source.path)/backend-core-artifact-repo"
mkdir -p "$(workspaces.source.path)/backend-core-artifact-repo"
find "$(workspaces.source.path)/backend-core-artifact-repo" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
case "$(params.source-host-path)" in
/home/ubuntu/.unidesk/ci/backend-core-artifacts/*) ;;
*) echo "backend_core_artifact_source_host_path_invalid=$(params.source-host-path)" >&2; exit 2 ;;
esac
source_name="$(basename "$(params.source-host-path)")"
source_dir="/prepared-source/$source_name"
test -f "$source_dir/.unidesk-source-commit"
prepared_commit="$(cat "$source_dir/.unidesk-source-commit")"
test "$prepared_commit" = "$(params.revision)"
cp -a "$source_dir/." "$(workspaces.source.path)/backend-core-artifact-repo/"
cd "$(workspaces.source.path)/backend-core-artifact-repo"
git fetch --depth=1 origin "$(params.revision)"
git checkout --detach FETCH_HEAD
resolved="$(git rev-parse HEAD)"
test "$resolved" = "$(params.revision)"
git cat-file -e "$resolved:src/components/backend-core/Dockerfile"
git cat-file -e "$resolved:src/components/backend-core/src"
git rev-parse HEAD | tee "$(workspaces.source.path)/backend-core-artifact-commit.txt"
test -f src/components/backend-core/Dockerfile
test -d src/components/backend-core/src
printf '%s\n' "$prepared_commit" | tee "$(workspaces.source.path)/backend-core-artifact-commit.txt"
- name: build-and-push
image: "$(params.app-image)"
imagePullPolicy: Never
@@ -354,13 +353,10 @@ spec:
local_image="unidesk/backend-core:$commit"
registry_image="$registry/unidesk/backend-core:$commit"
command -v docker
docker buildx version >/dev/null 2>&1 || docker buildx inspect default >/dev/null 2>&1
docker version >/dev/null
docker run --rm --network host rancher/mirrored-library-busybox:1.36.1 wget -q -O- "http://$registry/v2/" >/dev/null
docker buildx build \
--builder default \
--load \
DOCKER_BUILDKIT=0 docker build \
--network host \
--progress=plain \
--build-arg HTTP_PROXY=http://127.0.0.1:18789 \
--build-arg HTTPS_PROXY=http://127.0.0.1:18789 \
--build-arg ALL_PROXY=http://127.0.0.1:18789 \
@@ -401,6 +397,8 @@ spec:
- name: registry
type: string
default: 127.0.0.1:5000
- name: source-host-path
type: string
workspaces:
- name: shared-workspace
tasks:
@@ -416,6 +414,8 @@ spec:
value: "$(params.app-image)"
- name: registry
value: "$(params.registry)"
- name: source-host-path
value: "$(params.source-host-path)"
workspaces:
- name: source
workspace: shared-workspace