FROM rust:latest AS base WORKDIR app RUN set -eux; \ apt-get update; \ apt-get install -y cmake clang; RUN cargo install cargo-chef --version 0.1.23 # create an image for all of the repo sources FROM base AS sources COPY Cargo.toml /app COPY common /app/common COPY quic /app/quic COPY tools/xdp /app/tools/xdp # Don't include testing crates RUN rm -rf quic/s2n-quic-bench quic/s2n-quic-events quic/s2n-quic-sim # apply patch to use forked version of the webpki crate # see https://github.com/aws/s2n-quic/issues/1836 RUN git apply quic/s2n-quic-qns/etc/webpki.patch # create a planner image that forms the dependencies FROM sources AS planner RUN cargo chef prepare --recipe-path recipe.json # create a cacher image that builds the dependencies FROM base AS cacher COPY --from=planner /app/recipe.json recipe.json RUN cargo chef cook --recipe-path recipe.json # create an image that builds the final crate FROM sources AS builder # Copy over the cached dependencies COPY --from=cacher /app/target target COPY --from=cacher /usr/local/cargo /usr/local/cargo # build runner ARG release="false" RUN set -eux; \ if [ "$release" = "true" ]; then \ RUSTFLAGS="-C link-arg=-s -C panic=abort" \ cargo build --bin s2n-quic-qns --release; \ cp target/release/s2n-quic-qns .; \ else \ cargo build --bin s2n-quic-qns; \ cp target/debug/s2n-quic-qns .; \ fi; \ rm -rf target FROM martenseemann/quic-network-simulator-endpoint:latest ENV RUST_BACKTRACE="1" # copy entrypoint COPY quic/s2n-quic-qns/etc/run_endpoint.sh . RUN chmod +x run_endpoint.sh # copy runner COPY --from=builder /app/s2n-quic-qns /usr/bin/s2n-quic-qns RUN set -eux; \ chmod +x /usr/bin/s2n-quic-qns; \ ldd /usr/bin/s2n-quic-qns; \ # ensure the binary works \ s2n-quic-qns --help; \ echo done ARG tls ENV TLS="${tls}" # enable unstable crypto optimizations for testing ENV S2N_UNSTABLE_CRYPTO_OPT_TX=100 ENV S2N_UNSTABLE_CRYPTO_OPT_RX=100