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>
42 lines
2.4 KiB
Docker
42 lines
2.4 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.95-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
|
|
# the first cargo command needs this, although this crate does not use
|
|
# voelin-identity: the `cargo fetch` below, the only step that is given the agent.
|
|
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
|
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
|
COPY . .
|
|
# Only this step is given the agent, and it only fetches: no build script,
|
|
# procedural macro or test of the workspace runs in it. The build below has no
|
|
# ssh mount (so no agent socket and no key in reach of the code it compiles and
|
|
# runs) and is --offline, so it uses what this step fetched or fails.
|
|
RUN --mount=type=ssh,required=true \
|
|
cargo fetch --locked
|
|
RUN cargo build --release --locked --offline -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"]
|