# syntax=docker/dockerfile:1
# Build stage: compile the Rust workspace including examples
FROM rust:1.80-slim-bullseye AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
pkg-config \
libssl-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install rustup and nightly toolchain to enable edition2024 features during build
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH=/root/.cargo/bin:${PATH}
RUN rustup toolchain install nightly
# Build workspace with nightly toolchain to support newer Cargo features
WORKDIR /workspace
COPY . .
RUN cargo +nightly build --locked --examples
# Runtime stage: run the prebuilt binaries
FROM debian:bookworm-slim AS runtime
# Minimal runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libssl3 \
file \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /workspace
WORKDIR /workspace
# Copy the server example binary and ensure runtime has the directory
COPY --from=builder /workspace/target/debug/examples/server /usr/local/bin/server
# Expose the default QUIC server port (4433)
EXPOSE 4433
# Run the server example with the repository mounted at /workspace
CMD ["/usr/local/bin/server", "/workspace"]