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>
37 lines
2.0 KiB
Docker
37 lines
2.0 KiB
Docker
# 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
|
|
# Logs: docker logs -f tsgw (more: -e TSGW_LOG_LEVEL=debug; also to a file in
|
|
# 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 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 --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
|
|
# The database (and a log file, if set) live here; owned by the image's user
|
|
# (nonroot, 65532), so a new volume mounted here is writable too.
|
|
COPY --from=build --chown=65532:65532 /data /var/lib/tsgw
|
|
ENV TSGW_CONFIG=/etc/tsgw/tsgw.toml
|
|
WORKDIR /var/lib/tsgw
|
|
EXPOSE 7788
|
|
ENTRYPOINT ["/usr/local/bin/tsgw"]
|