perf: platform-ci-base image + in-place static build (no apk, no helper)

This commit is contained in:
ops 2026-06-02 02:08:57 +00:00
parent 7f4349feac
commit e9cd726565

View file

@ -40,7 +40,10 @@ runs:
OUR_IP="154.83.149.72" OUR_IP="154.83.149.72"
echo "::group::setup" echo "::group::setup"
apk add --no-cache git jq bind-tools >/dev/null 2>&1 || true # platform-ci-base bakes in git/jq/dig/rsync/bun — skip apk on the fast path,
# fall back to installing only if a tool is missing (e.g. stock docker:24 image).
command -v git >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 && command -v dig >/dev/null 2>&1 \
|| apk add --no-cache git jq bind-tools rsync >/dev/null 2>&1 || true
REPO="$IN_REPO"; REF="$IN_REF"; SHA="${IN_SHA:-manual}" REPO="$IN_REPO"; REF="$IN_REF"; SHA="${IN_SHA:-manual}"
SLUG=$(printf '%s' "$REPO" | tr 'A-Z/' 'a-z-') SLUG=$(printf '%s' "$REPO" | tr 'A-Z/' 'a-z-')
FRAG="/srv/platform/caddy/sites/${SLUG}.caddy" FRAG="/srv/platform/caddy/sites/${SLUG}.caddy"
@ -137,27 +140,22 @@ runs:
case "$DT" in case "$DT" in
static) static)
echo "::group::build (bun)" # build IN-PLACE — the job runs on platform-ci-base which has bun, so no
BH="build-${SLUG}-${SHA}" # throwaway helper + docker-cp round-trip. (Trade-off: the dev's build runs
docker rm -f "$BH" >/dev/null 2>&1 || true # in the privileged job container; consistent with the Phase-6 socket-accepted
trap 'docker rm -f "$BH" >/dev/null 2>&1 || true' EXIT # model. Revert to the sandboxed helper if that matters more than ~3s.)
docker run -d --name "$BH" -w /app oven/bun:1-alpine sleep 1200 >/dev/null echo "::group::build (bun, in-place)"
docker cp /tmp/repo/. "$BH:/app/" cd /tmp/repo
if docker exec -w /app "$BH" sh -c '[ -f bun.lock ] || [ -f bun.lockb ]'; then if [ -f bun.lock ] || [ -f bun.lockb ]; then bun install --frozen-lockfile; else bun install; fi
docker exec -w /app "$BH" sh -c 'bun install --frozen-lockfile' bun run build
else
docker exec -w /app "$BH" sh -c 'bun install'
fi
docker exec -w /app "$BH" sh -c 'bun run build'
echo "::endgroup::" echo "::endgroup::"
echo "::group::publish static → /srv/sites/$DOMAIN" echo "::group::publish static → /srv/sites/$DOMAIN"
[ -d "/tmp/repo/${BUILD_DIR}" ] || { echo "::error::build output '${BUILD_DIR}' not found"; exit 1; }
TMP="/srv/sites/.tmp-${SLUG}-${SHA}" TMP="/srv/sites/.tmp-${SLUG}-${SHA}"
rm -rf "$TMP"; mkdir -p "$TMP" rm -rf "$TMP"; mkdir -p "$TMP"
docker cp "$BH:/app/${BUILD_DIR}/." "$TMP/" \ cp -a "/tmp/repo/${BUILD_DIR}/." "$TMP/"
|| { echo "::error::build output '${BUILD_DIR}' not found"; exit 1; }
rm -rf "/srv/sites/${DOMAIN}"; mv "$TMP" "/srv/sites/${DOMAIN}" rm -rf "/srv/sites/${DOMAIN}"; mv "$TMP" "/srv/sites/${DOMAIN}"
docker rm -f "$BH" >/dev/null 2>&1 || true; trap - EXIT
echo " $(find "/srv/sites/${DOMAIN}" -type f | wc -l) files published" echo " $(find "/srv/sites/${DOMAIN}" -type f | wc -l) files published"
echo "::endgroup::" echo "::endgroup::"