From 2e4ead6f5aabbc48f3cc92510def47b6de4499a1 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Wed, 9 Aug 2023 16:15:51 -0400 Subject: [PATCH 1/8] self hosted docker builds --- .github/workflows/docker.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c3119db3780..d56e3b59bba 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -13,6 +13,8 @@ env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} IMAGE_NAME: ${{ github.repository_owner}}/lighthouse LCLI_IMAGE_NAME: ${{ github.repository_owner }}/lcli + # Enable self-hosted runners for the sigp repo only. + SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/lighthouse' }} jobs: # Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX @@ -44,7 +46,8 @@ jobs: VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }} build-docker-single-arch: name: build-docker-${{ matrix.binary }}${{ matrix.features.version_suffix }} - runs-on: ubuntu-22.04 + # Use self-hosted runners only on the sigp repo. + runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "large"]') || 'ubuntu-22.04' }} strategy: matrix: binary: [aarch64, @@ -68,24 +71,25 @@ jobs: steps: - uses: actions/checkout@v3 - name: Update Rust + if: env.SELF_HOSTED_RUNNERS == false run: rustup update stable - name: Dockerhub login run: | echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin - name: Cross build Lighthouse binary + if: env.SELF_HOSTED_RUNNERS == false run: | cargo install cross env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ matrix.features.env }} make build-${{ matrix.binary }} + - name: Make bin dir + if: env.SELF_HOSTED_RUNNERS == false + run: mkdir ./bin - name: Move cross-built binary into Docker scope (if ARM) if: startsWith(matrix.binary, 'aarch64') - run: | - mkdir ./bin; - mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin; + run: mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin - name: Move cross-built binary into Docker scope (if x86_64) if: startsWith(matrix.binary, 'x86_64') - run: | - mkdir ./bin; - mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin; + run: mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin - name: Map aarch64 to arm64 short arch if: startsWith(matrix.binary, 'aarch64') run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV From 0945e4d01e16fe9b9e9590ddc79ee808abe87fa4 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Thu, 10 Aug 2023 09:41:34 -0400 Subject: [PATCH 2/8] remove self hosted runner check where it might not be needed --- .github/workflows/docker.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d56e3b59bba..43738248469 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -77,12 +77,10 @@ jobs: run: | echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin - name: Cross build Lighthouse binary - if: env.SELF_HOSTED_RUNNERS == false run: | cargo install cross env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ matrix.features.env }} make build-${{ matrix.binary }} - name: Make bin dir - if: env.SELF_HOSTED_RUNNERS == false run: mkdir ./bin - name: Move cross-built binary into Docker scope (if ARM) if: startsWith(matrix.binary, 'aarch64') From 815ab8c8aedc996797c409d830f7f32efe85c652 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Thu, 10 Aug 2023 12:42:56 -0400 Subject: [PATCH 3/8] self hosted docker builds attempted fix (#4603) --- .github/workflows/docker.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 43738248469..edfedce87f9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -97,17 +97,22 @@ jobs: - name: Set modernity suffix if: endsWith(matrix.binary, '-portable') != true run: echo "MODERNITY_SUFFIX=-modern" >> $GITHUB_ENV; - # Install dependencies for emulation. Have to create a new builder to pick up emulation support. - - name: Build Dockerfile and push - run: | - docker run --privileged --rm tonistiigi/binfmt --install ${SHORT_ARCH} - docker buildx create --use --name cross-builder - docker buildx build \ - --platform=linux/${SHORT_ARCH} \ - --file ./Dockerfile.cross . \ - --tag ${IMAGE_NAME}:${VERSION}-${SHORT_ARCH}${VERSION_SUFFIX}${MODERNITY_SUFFIX}${FEATURE_SUFFIX} \ - --provenance=false \ - --push + + - name: Install QEMU + run: sudo apt-get update && sudo apt-get install -y qemu-user-static + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and push + uses: docker/build-push-action@v4 + with: + file: ./Dockerfile.cross + context: . + platforms: linux/${SHORT_ARCH} + push: true + tags: ${IMAGE_NAME}:${VERSION}-${SHORT_ARCH}${VERSION_SUFFIX}${MODERNITY_SUFFIX}${FEATURE_SUFFIX} + build-docker-multiarch: name: build-docker-multiarch${{ matrix.modernity }} runs-on: ubuntu-22.04 From 70d721b52befd9fe934297926881e38e17aabe20 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Thu, 10 Aug 2023 13:09:18 -0400 Subject: [PATCH 4/8] Fix env var references (#4604) * self hosted docker builds attempted fix * fix env var references in docker builds --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index edfedce87f9..367f26bcfa9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -109,9 +109,9 @@ jobs: with: file: ./Dockerfile.cross context: . - platforms: linux/${SHORT_ARCH} + platforms: linux/${{ env.SHORT_ARCH }} push: true - tags: ${IMAGE_NAME}:${VERSION}-${SHORT_ARCH}${VERSION_SUFFIX}${MODERNITY_SUFFIX}${FEATURE_SUFFIX} + tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}${{ env.MODERNITY_SUFFIX }}${{ env.FEATURE_SUFFIX }} build-docker-multiarch: name: build-docker-multiarch${{ matrix.modernity }} From 1b1fd8cb43b44850d4ff6da67eb7c3c1780ac9c5 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Thu, 10 Aug 2023 15:51:44 -0400 Subject: [PATCH 5/8] Fix manifest lists (#4605) * self hosted docker builds attempted fix * use imagetools instead of docker manifest --- .github/workflows/docker.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 367f26bcfa9..f5c8d5e4746 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -63,8 +63,6 @@ jobs: needs: [extract-version] env: - # We need to enable experimental docker features in order to use `docker buildx` - DOCKER_CLI_EXPERIMENTAL: enabled VERSION: ${{ needs.extract-version.outputs.VERSION }} VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }} FEATURE_SUFFIX: ${{ matrix.features.version_suffix }} @@ -121,20 +119,22 @@ jobs: matrix: modernity: ["", "-modern"] env: - # We need to enable experimental docker features in order to use `docker manifest` - DOCKER_CLI_EXPERIMENTAL: enabled VERSION: ${{ needs.extract-version.outputs.VERSION }} VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }} steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Dockerhub login run: | echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin + - name: Create and push multiarch manifest run: | - docker manifest create ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} \ - --amend ${IMAGE_NAME}:${VERSION}-arm64${VERSION_SUFFIX}${{ matrix.modernity }} \ - --amend ${IMAGE_NAME}:${VERSION}-amd64${VERSION_SUFFIX}${{ matrix.modernity }}; - docker manifest push ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} + docker buildx imagetools create -t ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} \ + ${IMAGE_NAME}:${VERSION}-arm64${VERSION_SUFFIX}${{ matrix.modernity }} \ + ${IMAGE_NAME}:${VERSION}-amd64${VERSION_SUFFIX}${{ matrix.modernity }}; + build-docker-lcli: runs-on: ubuntu-22.04 needs: [extract-version] From e871f8ce3e6655f67ef7584afdf364adedd6786c Mon Sep 17 00:00:00 2001 From: antondlr Date: Thu, 31 Aug 2023 14:46:34 +0200 Subject: [PATCH 6/8] switch from `topaz` to production builder --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f5c8d5e4746..5f561635d4e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -47,7 +47,7 @@ jobs: build-docker-single-arch: name: build-docker-${{ matrix.binary }}${{ matrix.features.version_suffix }} # Use self-hosted runners only on the sigp repo. - runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "large"]') || 'ubuntu-22.04' }} + runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "release"]') || 'ubuntu-22.04' }} strategy: matrix: binary: [aarch64, From f3f73cd731b3b1e5821a26e69096179f5c7ce7fd Mon Sep 17 00:00:00 2001 From: antondlr Date: Wed, 20 Sep 2023 08:52:20 +0200 Subject: [PATCH 7/8] multiarch buildx instance already present on SH --- .github/workflows/docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5f561635d4e..0126fcbc9fd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -97,9 +97,11 @@ jobs: run: echo "MODERNITY_SUFFIX=-modern" >> $GITHUB_ENV; - name: Install QEMU + if: env.SELF_HOSTED_RUNNERS == false run: sudo apt-get update && sudo apt-get install -y qemu-user-static - name: Set up Docker Buildx + if: env.SELF_HOSTED_RUNNERS == false uses: docker/setup-buildx-action@v2 - name: Build and push From eb0b9da1245019d425ca7dfc92e9a1c8fdedfe4d Mon Sep 17 00:00:00 2001 From: antondlr Date: Wed, 20 Sep 2023 10:07:29 +0200 Subject: [PATCH 8/8] correct syntax mistake --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0126fcbc9fd..938ae55f731 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -69,7 +69,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Update Rust - if: env.SELF_HOSTED_RUNNERS == false + if: env.SELF_HOSTED_RUNNERS == 'false' run: rustup update stable - name: Dockerhub login run: | @@ -97,11 +97,11 @@ jobs: run: echo "MODERNITY_SUFFIX=-modern" >> $GITHUB_ENV; - name: Install QEMU - if: env.SELF_HOSTED_RUNNERS == false + if: env.SELF_HOSTED_RUNNERS == 'false' run: sudo apt-get update && sudo apt-get install -y qemu-user-static - name: Set up Docker Buildx - if: env.SELF_HOSTED_RUNNERS == false + if: env.SELF_HOSTED_RUNNERS == 'false' uses: docker/setup-buildx-action@v2 - name: Build and push