From d9ad3e35f8648bfa2c1051c34771d74b51ed78dc Mon Sep 17 00:00:00 2001 From: Max Inden Date: Mon, 15 Jan 2024 09:36:00 +0100 Subject: [PATCH] ci: automate quic-network-simulator docker image build & push --- .github/workflows/qns.yml | 46 +++++++++++++++++++++++++++++++++++++++ qns/Dockerfile | 23 +++++--------------- qns/update.sh | 38 -------------------------------- 3 files changed, 51 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/qns.yml delete mode 100755 qns/update.sh diff --git a/.github/workflows/qns.yml b/.github/workflows/qns.yml new file mode 100644 index 0000000000..7663c29416 --- /dev/null +++ b/.github/workflows/qns.yml @@ -0,0 +1,46 @@ +name: qns (quic-network-simulator) + +on: + push: + branches: ["main", "docker"] # TODO: update + paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"] + pull_request: + branches: ["main"] + paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}-qns + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + file: qns/Dockerfile diff --git a/qns/Dockerfile b/qns/Dockerfile index dd18af0e25..8a602bf503 100644 --- a/qns/Dockerfile +++ b/qns/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=1.45.2 + RUST_VERSION=1.70.0 RUN set -eux; \ curl -sSLf "https://static.rust-lang.org/rustup/archive/1.22.1/x86_64-unknown-linux-gnu/rustup-init" -o rustup-init; \ @@ -33,35 +33,22 @@ RUN set -eux; \ RUN "$NSS_DIR"/build.sh --static -Ddisable_tests=1 -o -# Copy the .git directory from the local clone so that it is possible to create -# an image that includes local updates. -RUN mkdir -p /neqo-reference -ADD . /neqo-reference -RUN if [ -d /neqo-reference/.git ]; then \ - source=/neqo-reference; \ - else \ - source=https://github.com/mozilla/neqo; \ - fi; \ - git clone --depth 1 --branch "$NEQO_BRANCH" "$source" /neqo; \ - rm -rf /neqo-reference +ADD . /neqo RUN set -eux; \ cd /neqo; \ RUSTFLAGS="-g -C link-arg=-fuse-ld=lld" cargo build --release \ - --bin neqo-client --bin neqo-server; \ - cp target/release/neqo-client target; \ - cp target/release/neqo-server target; \ - rm -rf target/release + --bin neqo-client --bin neqo-server; # Copy only binaries to the final image to keep it small. FROM martenseemann/quic-network-simulator-endpoint:latest ENV LD_LIBRARY_PATH=/neqo/lib -COPY --from=buildimage /neqo/target/neqo-client /neqo/target/neqo-server /neqo/bin/ +COPY --from=buildimage /neqo/target/release/neqo-client /neqo/target/release/neqo-server /neqo/bin/ COPY --from=buildimage /dist/Release/lib/*.so /neqo/lib/ COPY --from=buildimage /dist/Release/bin/certutil /dist/Release/bin/pk12util /neqo/bin/ -COPY interop.sh /neqo/ +COPY qns/interop.sh /neqo/ RUN chmod +x /neqo/interop.sh ENTRYPOINT [ "/neqo/interop.sh" ] diff --git a/qns/update.sh b/qns/update.sh deleted file mode 100755 index 2243ee23a0..0000000000 --- a/qns/update.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -set -e - -if [[ "$1" == "-p" ]]; then - shift - push=1 -else - push=0 -fi - -branch="${1:-$(git rev-parse --abbrev-ref HEAD)}" -if [[ "$branch" == "main" ]]; then - tag="neqoquic/neqo-qns:latest" -else - tag="neqoquic/neqo-qns:${branch}" -fi - -cd "$(dirname "$0")" - -rev=$(git log -n 1 --format='format:%H') -if [[ "$rev" == "$(cat ".last-update-$branch")" ]]; then - echo "No change since $rev." - exit 0 -fi - -# This makes the local .git directory the source, allowing for the current -# build to be build and pushed. -[[ ! -e .git ]] || ! echo "Found .git directory. Script still active. Exiting." -trap 'rm -rf .git' EXIT -cp -R ../.git .git - -docker build -t "$tag" --build-arg NEQO_BRANCH="$branch" . -if [[ "$push" == "1" ]]; then - docker login - docker push "$tag" -fi - -echo "$rev" > ".last-update-$branch"