From 5547621cfab34296de48b4d19d6646a3abd88a99 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sun, 26 Jul 2026 02:38:31 +0300 Subject: [PATCH] Release: resolve containerized runner workspace Signed-off-by: faumaray --- .gitea/RELEASING.md | 6 +++- scripts/release.sh | 74 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/.gitea/RELEASING.md b/.gitea/RELEASING.md index 0e6daa8..f13b447 100644 --- a/.gitea/RELEASING.md +++ b/.gitea/RELEASING.md @@ -31,7 +31,11 @@ services: Leave `container.docker_host` at its generated default (`""`) so `act_runner` passes the detected Docker endpoint to job containers. Do not set it to `-`, which explicitly prevents that endpoint from being mounted. Restart the runner -after changing its configuration. +after changing its configuration. `scripts/release.sh` detects when it is +running inside the job container and translates the checked-out workspace +through that container's Docker mount table. This is required because bind +mount paths passed to the socket are resolved by the runner host daemon, not +inside the Actions job container. The SSH checkout steps pin the current `git.faumaray.ru` RSA host key. Its verified fingerprint is diff --git a/scripts/release.sh b/scripts/release.sh index 4b8f0d1..191cb13 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -205,10 +205,68 @@ container_path() { esac } +docker_daemon_path() { + local path=$1 + local container_reference=${ECHOION_DOCKER_CONTAINER_ID:-} + local mount_data= + local mount_source mount_destination + local best_source='' best_destination='' + + if [[ -z $container_reference ]]; then + container_reference=${JOB_CONTAINER_NAME:-${HOSTNAME:-}} + fi + + # A containerized CI job talks to the host Docker daemon through its + # socket. Bind-mount source paths are therefore interpreted in the daemon + # host namespace, not in this job container. Resolve the longest matching + # mount from the current container so nested release containers see the + # checked-out workspace instead of an empty host directory. + if [[ -n ${ECHOION_DOCKER_CONTAINER_ID:-} || + -f /.dockerenv || -f /run/.containerenv ]]; then + if [[ -n $container_reference ]]; then + mount_data=$( + docker inspect \ + --format '{{range .Mounts}}{{printf "%s\t%s\n" .Source .Destination}}{{end}}' \ + "$container_reference" 2>/dev/null || true + ) + fi + fi + + while IFS=$'\t' read -r mount_source mount_destination; do + [[ -n $mount_source && -n $mount_destination ]] || continue + case $path in + "$mount_destination"|"$mount_destination"/*) + if ((${#mount_destination} > ${#best_destination})); then + best_source=$mount_source + best_destination=$mount_destination + fi + ;; + *) + if [[ $mount_destination == / && $path == /* ]]; then + best_source=$mount_source + best_destination=$mount_destination + fi + ;; + esac + done <<<"$mount_data" + + if [[ -z $best_destination ]]; then + printf '%s\n' "$path" + elif [[ $path == "$best_destination" ]]; then + printf '%s\n' "$best_source" + elif [[ $best_destination == / ]]; then + printf '%s/%s\n' "${best_source%/}" "${path#/}" + else + printf '%s/%s\n' \ + "${best_source%/}" "${path#"$best_destination"/}" + fi +} + if ((use_container)); then command -v docker >/dev/null || die "docker is required for --container" container_build_dir=$(container_path "$build_dir") container_dist_dir=$(container_path "$dist_dir") + docker_source_dir=$(docker_daemon_path "$source_dir") image="echoion-release-builder:gcc-16.1.0" proxy_build_args=() proxy_run_args=() @@ -229,20 +287,22 @@ if ((use_container)); then container_args=( --rm --user "$(id -u):$(id -g)" - --volume "$source_dir:/workspace" + --volume "$docker_source_dir:/workspace" --workdir /workspace --env HOME=/tmp/echoion-release-home --env npm_config_cache=/tmp/echoion-npm-cache ) container_args+=("${proxy_run_args[@]}") if [[ -n $void_source ]]; then + docker_void_source=$(docker_daemon_path "$void_source") container_args+=( - --volume "$void_source:/workspace-deps/VoidLibrary:ro" + --volume "$docker_void_source:/workspace-deps/VoidLibrary:ro" ) fi if [[ -n $void_teamspeak_source ]]; then + docker_void_teamspeak_source=$(docker_daemon_path "$void_teamspeak_source") container_args+=( - --volume "$void_teamspeak_source:/workspace-deps/VoidTeamspeak:ro" + --volume "$docker_void_teamspeak_source:/workspace-deps/VoidTeamspeak:ro" ) fi if [[ -n ${SOURCE_DATE_EPOCH:-} ]]; then @@ -275,6 +335,14 @@ if ((use_container)); then release_args+=( --official-update-feed-url "$official_update_feed_url" ) + if [[ $docker_source_dir != "$source_dir" ]]; then + echo "release: mapped container workspace through the Docker daemon mount table" + fi + docker run --rm --platform linux/amd64 \ + --volume "$docker_source_dir:/workspace:ro" \ + "$image" \ + test -x /workspace/scripts/release.sh || + die "Docker daemon cannot access the checked-out source tree" docker run --platform linux/amd64 "${container_args[@]}" "$image" \ bash scripts/release.sh "${release_args[@]}" exit