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
@@ -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 \
|
||||
|
||||
Reference in new issue
Block a user