# 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"]