feat(relay): add Dockerfile (#1661)

This adds a basic Dockerfile for the relay so users and devs can easily
start it.
This commit is contained in:
Thomas Eizinger
2023-06-15 19:59:53 +02:00
committed by GitHub
parent 6491ad13c9
commit a491521ef7
3 changed files with 29 additions and 0 deletions

1
rust/.dockerignore Normal file
View File

@@ -0,0 +1 @@
target/

23
rust/relay.Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
# syntax=docker/dockerfile:1.5-labs
FROM rust:1.70-slim as builder
WORKDIR /workspace
ADD . .
RUN --mount=type=cache,target=./target \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/rustup \
rustup target add x86_64-unknown-linux-musl && \
cargo build --release --bin relay --target x86_64-unknown-linux-musl
RUN --mount=type=cache,target=./target \
mv ./target/x86_64-unknown-linux-musl/release/relay /usr/local/bin/relay
FROM scratch
COPY --from=builder /usr/local/bin/relay /usr/local/bin/relay
ENV RUST_BACKTRACE=1
EXPOSE 3478/udp
EXPOSE 49152-65535/udp
# This purposely does not include an `init` process. Use `docker run --init` for proper signal handling.
ENTRYPOINT ["relay"]

View File

@@ -22,6 +22,11 @@ You can build the server using: `cargo build --release --bin relay`
For a detailed help text and available configuration options, run `cargo run --bin relay -- --help`.
## Docker
There is a docker image one directory up from this README: [Dockerfile](../relay.Dockerfile).
The Rust binary itself does not include any signal handling, thus you need to run the container with `--init` if you want to be able to CTRL+C the running container.
## Design
The relay is designed in a sans-IO fashion, meaning the core components do not cause side effects but operate as pure, synchronous state machines.