Files
VoelinClient/scripts/docker-build.sh
T
faumarayandClaude Sonnet 5.5 91dce84b36 release and the images: the agent only for cargo fetch, stopped after the builds, never on a runner that may print the key
release.yml checks the runner version before any step names the secret (same
gate as ci.yml), starts the ssh-agent only on the positive flag, and stops it in
an always() step right after the last build, so the artifact upload and the
release draft have neither the key nor the socket. The four Dockerfiles (linux,
windows, android, the gateway image) give the agent to `RUN cargo fetch --locked`
only; the build after it has no ssh mount and is offline (--offline, and
CARGO_NET_OFFLINE for the Android Gradle task, which starts cargo-ndk).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 02:55:23 +03:00

64 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the packages in Docker, the same ones CI uploads (docs/building.md).
#
# scripts/docker-build.sh [linux|windows|android|all] [docker build args…]
#
# Output goes to dist/<platform>/. Needs Docker with BuildKit (Docker 23+, or
# docker buildx). Extra arguments go to `docker build`, e.g.
# scripts/docker-build.sh android --build-arg ABIS=arm64-v8a
#
# The workspace depends on the private VoelinProtocol repository, which the
# build fetches over SSH with your ssh-agent (`docker build --ssh default`):
# the agent must hold a key that can read it (docs/building.md, "Depending on
# VoelinProtocol"). The key stays in the agent, never in the image, and only the
# Dockerfile's `cargo fetch` step is given the agent: the build after it is
# offline.
#
# Behind an HTTPS proxy, HTTPS_PROXY/HTTP_PROXY/NO_PROXY are passed on to the
# build; a proxy on this machine's loopback is reached with host networking.
# If the proxy inspects TLS, point BUILD_CA_CERT at its CA certificate (PEM):
# the builds then trust it.
set -euo pipefail
cd "$(dirname "$0")/.."
platform=${1:-all}
shift || true
case "$platform" in
linux | windows | android) platforms=("$platform") ;;
all) platforms=(linux windows android) ;;
*) echo "usage: $0 [linux|windows|android|all] [docker build args…]" >&2; exit 2 ;;
esac
# The build's cargo needs VoelinProtocol; fail here, not after the toolchain
# stage, when the agent is missing or empty.
if ! ssh-add -l > /dev/null 2>&1; then
cat >&2 <<'MSG'
docker-build.sh: no ssh-agent with a key that can read Voelin/VoelinProtocol.
Start one and add the key, then run this again:
eval "$(ssh-agent -s)" && ssh-add ~/.ssh/<key>
docs/building.md ("Depending on VoelinProtocol") has the details.
MSG
exit 1
fi
args=(--ssh default)
for var in HTTPS_PROXY https_proxy HTTP_PROXY http_proxy NO_PROXY no_proxy; do
if [[ -n ${!var:-} ]]; then
args+=(--build-arg "$var=${!var}")
case "${!var}" in
*://127.* | *://localhost*) args+=(--network host) ;;
esac
fi
done
if [[ -n ${BUILD_CA_CERT:-} ]]; then
args+=(--secret "id=ca,src=$BUILD_CA_CERT")
fi
for p in "${platforms[@]}"; do
echo "== $p → dist/$p"
DOCKER_BUILDKIT=1 docker build -f "docker/$p.Dockerfile" -o "dist/$p" "${args[@]}" "$@" .
ls -l "dist/$p"
done