Self hosted docker builds (#4592)
## Issue Addressed We're OOM'ing on Docker builds on the Deneb branch https://github.com/sigp/lighthouse/issues/3929 Are we ok to self host automated docker builds? Co-authored-by: realbigsean <seananderson33@gmail.com> Co-authored-by: realbigsean <sean@sigmaprime.io> Co-authored-by: antondlr <anton@delaruelle.net>
This commit is contained in:
parent
fe3bd03234
commit
082bb2d638
61
.github/workflows/docker.yml
vendored
61
.github/workflows/docker.yml
vendored
@ -17,6 +17,8 @@ env:
|
|||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
IMAGE_NAME: ${{ github.repository_owner}}/lighthouse
|
IMAGE_NAME: ${{ github.repository_owner}}/lighthouse
|
||||||
LCLI_IMAGE_NAME: ${{ github.repository_owner }}/lcli
|
LCLI_IMAGE_NAME: ${{ github.repository_owner }}/lcli
|
||||||
|
# Enable self-hosted runners for the sigp repo only.
|
||||||
|
SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/lighthouse' }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX
|
# Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX
|
||||||
@ -48,7 +50,8 @@ jobs:
|
|||||||
VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }}
|
VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }}
|
||||||
build-docker-single-arch:
|
build-docker-single-arch:
|
||||||
name: build-docker-${{ matrix.binary }}${{ matrix.features.version_suffix }}
|
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", "release"]') || 'ubuntu-22.04' }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
binary: [aarch64,
|
binary: [aarch64,
|
||||||
@ -64,14 +67,13 @@ jobs:
|
|||||||
|
|
||||||
needs: [extract-version]
|
needs: [extract-version]
|
||||||
env:
|
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: ${{ needs.extract-version.outputs.VERSION }}
|
||||||
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
|
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
|
||||||
FEATURE_SUFFIX: ${{ matrix.features.version_suffix }}
|
FEATURE_SUFFIX: ${{ matrix.features.version_suffix }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Update Rust
|
- name: Update Rust
|
||||||
|
if: env.SELF_HOSTED_RUNNERS == 'false'
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- name: Dockerhub login
|
- name: Dockerhub login
|
||||||
run: |
|
run: |
|
||||||
@ -80,16 +82,14 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cargo install cross
|
cargo install cross
|
||||||
env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ matrix.features.env }} make build-${{ matrix.binary }}
|
env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ matrix.features.env }} make build-${{ matrix.binary }}
|
||||||
|
- name: Make bin dir
|
||||||
|
run: mkdir ./bin
|
||||||
- name: Move cross-built binary into Docker scope (if ARM)
|
- name: Move cross-built binary into Docker scope (if ARM)
|
||||||
if: startsWith(matrix.binary, 'aarch64')
|
if: startsWith(matrix.binary, 'aarch64')
|
||||||
run: |
|
run: mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin
|
||||||
mkdir ./bin;
|
|
||||||
mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin;
|
|
||||||
- name: Move cross-built binary into Docker scope (if x86_64)
|
- name: Move cross-built binary into Docker scope (if x86_64)
|
||||||
if: startsWith(matrix.binary, 'x86_64')
|
if: startsWith(matrix.binary, 'x86_64')
|
||||||
run: |
|
run: mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin
|
||||||
mkdir ./bin;
|
|
||||||
mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin;
|
|
||||||
- name: Map aarch64 to arm64 short arch
|
- name: Map aarch64 to arm64 short arch
|
||||||
if: startsWith(matrix.binary, 'aarch64')
|
if: startsWith(matrix.binary, 'aarch64')
|
||||||
run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV
|
run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV
|
||||||
@ -99,17 +99,24 @@ jobs:
|
|||||||
- name: Set modernity suffix
|
- name: Set modernity suffix
|
||||||
if: endsWith(matrix.binary, '-portable') != true
|
if: endsWith(matrix.binary, '-portable') != true
|
||||||
run: echo "MODERNITY_SUFFIX=-modern" >> $GITHUB_ENV;
|
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
|
- name: Install QEMU
|
||||||
run: |
|
if: env.SELF_HOSTED_RUNNERS == 'false'
|
||||||
docker run --privileged --rm tonistiigi/binfmt --install ${SHORT_ARCH}
|
run: sudo apt-get update && sudo apt-get install -y qemu-user-static
|
||||||
docker buildx create --use --name cross-builder
|
|
||||||
docker buildx build \
|
- name: Set up Docker Buildx
|
||||||
--platform=linux/${SHORT_ARCH} \
|
if: env.SELF_HOSTED_RUNNERS == 'false'
|
||||||
--file ./Dockerfile.cross . \
|
uses: docker/setup-buildx-action@v2
|
||||||
--tag ${IMAGE_NAME}:${VERSION}-${SHORT_ARCH}${VERSION_SUFFIX}${MODERNITY_SUFFIX}${FEATURE_SUFFIX} \
|
|
||||||
--provenance=false \
|
- name: Build and push
|
||||||
--push
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: ./Dockerfile.cross
|
||||||
|
context: .
|
||||||
|
platforms: linux/${{ env.SHORT_ARCH }}
|
||||||
|
push: true
|
||||||
|
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}${{ env.MODERNITY_SUFFIX }}${{ env.FEATURE_SUFFIX }}
|
||||||
|
|
||||||
build-docker-multiarch:
|
build-docker-multiarch:
|
||||||
name: build-docker-multiarch${{ matrix.modernity }}
|
name: build-docker-multiarch${{ matrix.modernity }}
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
@ -118,20 +125,22 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
modernity: ["", "-modern"]
|
modernity: ["", "-modern"]
|
||||||
env:
|
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: ${{ needs.extract-version.outputs.VERSION }}
|
||||||
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
|
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Dockerhub login
|
- name: Dockerhub login
|
||||||
run: |
|
run: |
|
||||||
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
|
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
|
||||||
|
|
||||||
- name: Create and push multiarch manifest
|
- name: Create and push multiarch manifest
|
||||||
run: |
|
run: |
|
||||||
docker manifest create ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} \
|
docker buildx imagetools create -t ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} \
|
||||||
--amend ${IMAGE_NAME}:${VERSION}-arm64${VERSION_SUFFIX}${{ matrix.modernity }} \
|
${IMAGE_NAME}:${VERSION}-arm64${VERSION_SUFFIX}${{ matrix.modernity }} \
|
||||||
--amend ${IMAGE_NAME}:${VERSION}-amd64${VERSION_SUFFIX}${{ matrix.modernity }};
|
${IMAGE_NAME}:${VERSION}-amd64${VERSION_SUFFIX}${{ matrix.modernity }};
|
||||||
docker manifest push ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }}
|
|
||||||
build-docker-lcli:
|
build-docker-lcli:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
needs: [extract-version]
|
needs: [extract-version]
|
||||||
|
Loading…
Reference in New Issue
Block a user