Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use AL2023 for qns image #2094

Merged
merged 4 commits into from
Jan 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 60 additions & 29 deletions quic/s2n-quic-qns/etc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
####################
# Base Build Image #
####################
FROM rust:latest AS rust-base
FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal AS rust-base

RUN set -eux; \
dnf makecache --refresh; \
dnf install -y gcc cmake; \
dnf clean all; \
rm -rf /var/cache/yum; \
curl https://sh.rustup.rs -sSf | bash -s -- -y;

WORKDIR app

RUN set -eux; \
apt-get update; \
apt-get install -y cmake clang;

RUN cargo install cargo-chef --version 0.1.23
source /root/.cargo/env; \
cargo install cargo-chef --version 0.1.62 --locked; \
cargo install cargo-auditable --version 0.6.1 --locked;

################
# Source image #
Expand All @@ -20,64 +26,81 @@ FROM rust-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
RUN set -eux; \
sed -i '/xdp/d' quic/s2n-quic-platform/Cargo.toml; \
sed -i '/xdp/d' quic/s2n-quic-qns/Cargo.toml; \
sed -i '/xdp/d' quic/s2n-quic/Cargo.toml; \
rm -rf quic/s2n-quic-bench quic/s2n-quic-events quic/s2n-quic-sim

#################
# Planner image #
#################
# create a planner image that forms the dependencies
FROM sources AS planner
RUN cargo chef prepare --recipe-path recipe.json

################
# Cacher image #
################
# create a cacher image that builds the dependencies
FROM rust-base AS cacher
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json
RUN set -eux; \
source /root/.cargo/env; \
cargo chef prepare --recipe-path recipe.json;

#################
# Builder image #
#################
# 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
COPY --from=planner /app/recipe.json recipe.json

ENV RUSTFLAGS_REL="-C link-arg=-s -C panic=abort --cfg s2n_internal_dev"
ENV RUSTFLAGS_DEV="--cfg s2n_internal_dev"

# build runner
ARG release="false"

RUN set -eux; \
source /root/.cargo/env; \
if [ "$release" = "true" ]; then \
RUSTFLAGS="$RUSTFLAGS_REL" \
cargo chef cook --release --recipe-path recipe.json; \
else \
RUSTFLAGS="$RUSTFLAGS_DEV" \
cargo chef cook --recipe-path recipe.json; \
fi;

# restore the correct sources - cargo-chef replaces them with empty files
COPY --from=sources /app/common /app/common
COPY --from=sources /app/quic /app/quic

# build runner
RUN set -eux; \
source /root/.cargo/env; \
if [ "$release" = "true" ]; then \
RUSTFLAGS="-C link-arg=-s -C panic=abort --cfg s2n_internal_dev" \
cargo build --bin s2n-quic-qns --release; \
RUSTFLAGS="$RUSTFLAGS_REL" \
cargo auditable build -p s2n-quic-qns --bin s2n-quic-qns --release; \
cp target/release/s2n-quic-qns .; \
else \
RUSTFLAGS="--cfg s2n_internal_dev" \
cargo build --bin s2n-quic-qns; \
RUSTFLAGS="$RUSTFLAGS_DEV" \
cargo auditable build -p s2n-quic-qns --bin s2n-quic-qns; \
cp target/debug/s2n-quic-qns .; \
fi; \
rm -rf target

#######################
# Endpoint base image #
#######################
FROM ubuntu:latest AS endpoint-base
FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal AS endpoint-base

ENV RUST_BACKTRACE="1"

ARG sim_hash="1f569016bcd9f7076fc9fd932c1415d28d3020f7"

RUN set -eux; \
apt-get update; \
apt-get install -y wget net-tools iputils-ping tcpdump ethtool iperf3 iproute2; \
wget https://raw.githubusercontent.com/marten-seemann/quic-network-simulator/${sim_hash}/endpoint/setup.sh; \
dnf makecache --refresh; \
dnf install -y net-tools iputils ethtool iproute hostname; \
dnf clean all; \
rm -rf /var/cache/yum; \
curl -o setup.sh https://raw.githubusercontent.com/marten-seemann/quic-network-simulator/${sim_hash}/endpoint/setup.sh; \
chmod +x setup.sh; \
wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh; \
curl -o wait-for-it.sh https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh; \
chmod +x wait-for-it.sh;

ARG tls
Expand Down Expand Up @@ -105,14 +128,21 @@ RUN set -eux; \
ldd /usr/bin/s2n-quic-qns; \
# ensure the binary works \
s2n-quic-qns --help; \
s2n-quic-qns-release --help; \
s2n-quic-qns --help | grep interop; \
s2n-quic-qns-release --help | grep interop; \
echo done

###############
# iperf image #
###############
FROM endpoint-base AS iperf

RUN set -eux; \
dnf makecache --refresh; \
dnf install -y iperf3; \
dnf clean all; \
rm -rf /var/cache/yum;

COPY --from=sources /app/quic/s2n-quic-qns/benchmark/iperf/run.sh run_endpoint.sh
RUN chmod +x run_endpoint.sh

Expand All @@ -132,5 +162,6 @@ RUN set -eux; \
ldd /usr/bin/s2n-quic-qns; \
# ensure the binary works \
s2n-quic-qns --help; \
s2n-quic-qns --help | grep interop; \
echo done

Loading