Adds support for deploying the `moq-quinn` relay server to fly.io
This commit is contained in:
Mike English 2023-09-07 16:02:07 -04:00 committed by GitHub
parent 73f450aa91
commit 48de6a3f5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 0 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
media/*.mp4
target/*
cert/*

44
Dockerfile Normal file
View File

@ -0,0 +1,44 @@
FROM rust:latest as builder
# Make a fake Rust app to keep a cached layer of compiled crates
RUN USER=root cargo new app
WORKDIR /usr/src/app
COPY Cargo.toml Cargo.lock ./
RUN mkdir -p moq-transport/src moq-quinn/src moq-warp/src moq-pub/src
COPY moq-transport/Cargo.toml moq-transport/Cargo.toml
COPY moq-quinn/Cargo.toml moq-quinn/Cargo.toml
COPY moq-pub/Cargo.toml moq-pub/Cargo.toml
COPY moq-warp/Cargo.toml moq-warp/Cargo.toml
RUN touch moq-transport/src/lib.rs
RUN touch moq-warp/src/lib.rs
RUN touch moq-pub/src/lib.rs
RUN touch moq-quinn/src/lib.rs
RUN sed -i '/default-run.*/d' moq-quinn/Cargo.toml
# Will build all dependent crates in release mode
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/src/app/target \
cargo build --release
# Copy the rest
COPY . .
# Build (install) the actual binaries
RUN cargo install --path moq-quinn
# Runtime image
FROM rust:latest
# Run as "app" user
RUN useradd -ms /bin/bash app
USER app
WORKDIR /app
# Get compiled binaries from builder's cargo install directory
COPY --from=builder /usr/local/cargo/bin/moq-quinn /app/moq-quinn
ADD entrypoint.sh .
# No CMD or ENTRYPOINT, see fly.toml with `cmd` override.

8
entrypoint.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env sh
mkdir cert
# Nothing to see here...
echo "$MOQ_CRT" | base64 -d > cert/moq-demo.crt
echo "$MOQ_KEY" | base64 -d > cert/moq-demo.key
RUST_LOG=info ./moq-quinn --cert cert/moq-demo.crt --key cert/moq-demo.key

19
fly.toml Normal file
View File

@ -0,0 +1,19 @@
app = "englishm-moq-relay"
kill_signal = "SIGINT"
kill_timeout = 5
[env]
PORT = "4443"
[experimental]
cmd = "./entrypoint.sh"
[[services]]
internal_port = 4443
protocol = "udp"
[services.concurrency]
hard_limit = 25
soft_limit = 20
[[services.ports]]
port = "4443"