Let the Docker builds fetch the private VoelinProtocol repository with an ssh-agent
Every cargo command in the images (linux, windows, android and the gateway image) failed for the same reason as the CI job: Cargo resolves the whole workspace, which includes the git dependency voelin-identity on the private Voelin/VoelinProtocol repository, and the images had no SSH access to it. The crates that depend on voelin-identity are voelin-store and, through it, voelin-core, voelin-ui, voelin-ui-vm, voelin-android and voelinctl; the gateway crate does not, but `cargo build -p voelin-gateway` fails without access too (checked with an empty CARGO_HOME), so its Dockerfile needs the same. Each cargo RUN gets --mount=type=ssh,required=true: the build is handed the caller's ssh-agent (docker build --ssh default), the key stays in the agent and never reaches a layer or the build context, and a build without --ssh fails at that step with "unset ssh forward key default". The build stage copies the host key committed in .gitea/known_hosts to /etc/ssh/ssh_known_hosts and sets CARGO_NET_GIT_FETCH_WITH_CLI=true, so that Cargo uses the system git and ssh. The toolchain stages install git and openssh-client where they were missing; the gateway Dockerfile gets the syntax directive the others already have. scripts/docker-build.sh passes --ssh default and stops early, with a message, when ssh-add -l shows no agent or no key. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
437b508047
commit
b89116c0f4
5 files changed
+93
-24
No files matched your search
@@ -1,4 +1,9 @@
|
||||
# Build: docker build -f crates/voelin-gateway/Dockerfile -t tsgw .
|
||||
# syntax=docker/dockerfile:1
|
||||
# Build: docker build --ssh default -f crates/voelin-gateway/Dockerfile -t tsgw .
|
||||
# (--ssh default hands the build your ssh-agent, which must hold a key that
|
||||
# can read the private VoelinProtocol repository: docs/building.md,
|
||||
# "Depending on VoelinProtocol". The gateway itself does not use it, but
|
||||
# Cargo resolves the whole workspace, which includes voelin-identity.)
|
||||
# Run: docker run -d --name tsgw --init --restart unless-stopped \
|
||||
# -v ./tsgw.toml:/etc/tsgw/tsgw.toml:ro -v tsgw-data:/var/lib/tsgw \
|
||||
# -e TSGW_QUERY_PASSWORD=… -p 7788:7788 tsgw
|
||||
@@ -6,9 +11,19 @@
|
||||
# the volume: -e TSGW_LOG_FILE=logs/tsgw.log). See docs/gateway-admin.md.
|
||||
FROM rust:1.94-bookworm AS build
|
||||
WORKDIR /src
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cmake libasound2-dev && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cmake git libasound2-dev openssh-client && rm -rf /var/lib/apt/lists/*
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
# over SSH by Cargo through the system git, with the agent that
|
||||
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
|
||||
# the key stays in the agent and never reaches a layer. The host key is the
|
||||
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
|
||||
# every cargo command needs this, although this crate does not use
|
||||
# voelin-identity.
|
||||
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
||||
COPY . .
|
||||
RUN cargo build --release --locked -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data
|
||||
RUN --mount=type=ssh,required=true \
|
||||
cargo build --release --locked -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data
|
||||
|
||||
FROM gcr.io/distroless/cc-debian12:nonroot
|
||||
COPY --from=build /tsgw /usr/local/bin/tsgw
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
# Android APKs (docs/building.md, docs/android.md): a debug APK, installable
|
||||
# as is, for arm64-v8a and x86_64 (emulators).
|
||||
#
|
||||
# docker build -f docker/android.Dockerfile -o dist/android .
|
||||
# docker build -f docker/android.Dockerfile --build-arg ABIS=arm64-v8a -o dist/android .
|
||||
# docker build --ssh default -f docker/android.Dockerfile -o dist/android .
|
||||
# docker build --ssh default -f docker/android.Dockerfile --build-arg ABIS=arm64-v8a -o dist/android .
|
||||
#
|
||||
# or scripts/docker-build.sh android. A signed release APK needs your keystore
|
||||
# (docs/release.md), passed as build secrets:
|
||||
# or scripts/docker-build.sh android. --ssh default hands the build your
|
||||
# ssh-agent, which must hold a key that can read the private VoelinProtocol
|
||||
# repository (docs/building.md, "Depending on VoelinProtocol"). A signed
|
||||
# release APK needs your keystore (docs/release.md), passed as build secrets:
|
||||
#
|
||||
# docker build -f docker/android.Dockerfile --build-arg APK=release \
|
||||
# docker build --ssh default -f docker/android.Dockerfile --build-arg APK=release \
|
||||
# --secret id=keystore,src=release.jks --secret id=signing,src=signing.env \
|
||||
# -o dist/android .
|
||||
#
|
||||
@@ -21,8 +23,8 @@ FROM ubuntu:24.04 AS toolchain
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# JDK 17 (Gradle, the Android Gradle plugin), CMake + Ninja (the bundled libopus).
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl ninja-build openjdk-17-jdk-headless \
|
||||
pkg-config python3 unzip \
|
||||
build-essential ca-certificates cmake curl git ninja-build openjdk-17-jdk-headless \
|
||||
openssh-client pkg-config python3 unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Extra CA certificates (PEM, one or more), for building behind a
|
||||
@@ -83,8 +85,18 @@ ARG APK=debug
|
||||
# supplies a fresh non-secret nonce so a rotated key cannot reuse an old APK.
|
||||
ARG SIGNING_CACHE_BUST=unsigned
|
||||
WORKDIR /src
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
# over SSH by Cargo through the system git, with the agent that
|
||||
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
|
||||
# the key stays in the agent and never reaches a layer. The host key is the
|
||||
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
|
||||
# every cargo command needs this (Gradle's cargo-ndk inherits the agent and the
|
||||
# variable below).
|
||||
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
||||
COPY . .
|
||||
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
RUN --mount=type=ssh,required=true \
|
||||
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,id=voelin-target-android,target=/src/target \
|
||||
--mount=type=cache,id=voelin-gradle,target=/root/.gradle \
|
||||
--mount=type=secret,id=keystore,required=false \
|
||||
|
||||
+17
-5
@@ -5,17 +5,20 @@
|
||||
# gateway (servers) as tsgw-<version>-linux-x86_64.tar.gz and
|
||||
# tsgw_<version>_amd64.deb.
|
||||
#
|
||||
# docker build -f docker/linux.Dockerfile -o dist/linux .
|
||||
# docker build --ssh default -f docker/linux.Dockerfile -o dist/linux .
|
||||
#
|
||||
# or scripts/docker-build.sh linux. The cargo registry and target directory
|
||||
# live in cache mounts, so rebuilds are incremental.
|
||||
# or scripts/docker-build.sh linux. --ssh default hands the build your
|
||||
# ssh-agent, which must hold a key that can read the private VoelinProtocol
|
||||
# repository (docs/building.md, "Depending on VoelinProtocol"). The cargo
|
||||
# registry and target directory live in cache mounts, so rebuilds are
|
||||
# incremental.
|
||||
|
||||
FROM ubuntu:24.04 AS toolchain
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# The same libraries as CI (.github/actions/system-deps), plus dpkg-dev for
|
||||
# the .deb's dependencies and patchelf for the .tar.gz's bundled libraries.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl dpkg-dev patchelf pkg-config \
|
||||
build-essential ca-certificates cmake curl dpkg-dev git openssh-client patchelf pkg-config \
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev \
|
||||
libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
@@ -37,8 +40,17 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
||||
|
||||
FROM toolchain AS build
|
||||
WORKDIR /src
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
# over SSH by Cargo through the system git, with the agent that
|
||||
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
|
||||
# the key stays in the agent and never reaches a layer. The host key is the
|
||||
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
|
||||
# every cargo command needs this.
|
||||
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
||||
COPY . .
|
||||
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
RUN --mount=type=ssh,required=true \
|
||||
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,id=voelin-target-linux,target=/src/target \
|
||||
cargo build --release --locked -p voelin-ui -p voelin-gateway \
|
||||
&& scripts/package.sh linux /out
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
# voelin-<version>-windows-x86_64.zip with voelin.exe, and the NSIS installer
|
||||
# voelin-<version>-setup.exe.
|
||||
#
|
||||
# docker build -f docker/windows.Dockerfile -o dist/windows .
|
||||
# docker build --ssh default -f docker/windows.Dockerfile -o dist/windows .
|
||||
#
|
||||
# or scripts/docker-build.sh windows. This builds for x86_64-pc-windows-gnu
|
||||
# with mingw-w64; CI's Windows jobs build the MSVC target on Windows. Both run
|
||||
# on Windows 10 and 11. Unsigned, like CI's (signing: docs/release.md).
|
||||
# or scripts/docker-build.sh windows. --ssh default hands the build your
|
||||
# ssh-agent, which must hold a key that can read the private VoelinProtocol
|
||||
# repository (docs/building.md, "Depending on VoelinProtocol").
|
||||
#
|
||||
# This builds for x86_64-pc-windows-gnu with mingw-w64; CI's Windows jobs build
|
||||
# the MSVC target on Windows. Both run on Windows 10 and 11. Unsigned, like
|
||||
# CI's (signing: docs/release.md).
|
||||
|
||||
FROM ubuntu:24.04 AS toolchain
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
@@ -16,8 +20,8 @@ ARG DEBIAN_FRONTEND=noninteractive
|
||||
# assembly), CMake (the bundled libopus, aws-lc), Meson and Ninja (dav1d),
|
||||
# NSIS (the installer), zip and unzip.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl git meson mingw-w64 nasm ninja-build nsis perl \
|
||||
pkg-config unzip zip \
|
||||
build-essential ca-certificates cmake curl git meson mingw-w64 nasm ninja-build nsis \
|
||||
openssh-client perl pkg-config unzip zip \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix \
|
||||
&& update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
|
||||
@@ -89,9 +93,18 @@ ENV VPX_LIB_DIR=/opt/libvpx/lib VPX_INCLUDE_DIR=/opt/libvpx/include \
|
||||
SYSTEM_DEPS_DAV1D_NO_PKG_CONFIG=1 SYSTEM_DEPS_DAV1D_SEARCH_NATIVE=/opt/dav1d/lib \
|
||||
SYSTEM_DEPS_DAV1D_LIB=dav1d SYSTEM_DEPS_DAV1D_LINK=static
|
||||
WORKDIR /src
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
# over SSH by Cargo through the system git, with the agent that
|
||||
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
|
||||
# the key stays in the agent and never reaches a layer. The host key is the
|
||||
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
|
||||
# every cargo command needs this.
|
||||
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
||||
COPY . .
|
||||
# FFmpeg's LGPL DLLs go into the packages (scripts/fetch-ffmpeg-windows.sh).
|
||||
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
RUN --mount=type=ssh,required=true \
|
||||
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,id=voelin-target-windows,target=/src/target \
|
||||
cargo build --release --locked --target x86_64-pc-windows-gnu -p voelin-ui \
|
||||
&& scripts/fetch-ffmpeg-windows.sh /tmp/ffmpeg \
|
||||
|
||||
+18
-1
@@ -7,6 +7,11 @@
|
||||
# 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.
|
||||
#
|
||||
# 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):
|
||||
@@ -23,7 +28,19 @@ case "$platform" in
|
||||
*) echo "usage: $0 [linux|windows|android|all] [docker build args…]" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
args=()
|
||||
# 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}")
|
||||
|
||||
Reference in new issue
Block a user