2020-12-09 06:06:37 +00:00
|
|
|
name: docker
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- unstable
|
|
|
|
- stable
|
2023-06-05 14:41:11 +00:00
|
|
|
- deneb-free-blobs
|
2022-01-31 22:55:03 +00:00
|
|
|
tags:
|
|
|
|
- v*
|
2020-12-09 06:06:37 +00:00
|
|
|
|
2023-08-14 03:16:03 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-12-09 06:06:37 +00:00
|
|
|
env:
|
|
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
2021-07-21 03:24:23 +00:00
|
|
|
IMAGE_NAME: ${{ github.repository_owner}}/lighthouse
|
|
|
|
LCLI_IMAGE_NAME: ${{ github.repository_owner }}/lcli
|
2023-08-09 20:15:51 +00:00
|
|
|
# Enable self-hosted runners for the sigp repo only.
|
|
|
|
SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/lighthouse' }}
|
2020-12-09 06:06:37 +00:00
|
|
|
|
|
|
|
jobs:
|
2022-01-31 22:55:03 +00:00
|
|
|
# Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX
|
|
|
|
# which is either empty or `-unstable`.
|
|
|
|
#
|
|
|
|
# It would be nice if the arch didn't get spliced into the version between `latest` and
|
|
|
|
# `unstable`, but for now we keep the two parts of the version separate for backwards
|
|
|
|
# compatibility.
|
|
|
|
extract-version:
|
2022-11-13 22:40:44 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-09 06:06:37 +00:00
|
|
|
steps:
|
2022-01-31 22:55:03 +00:00
|
|
|
- name: Extract version (if stable)
|
|
|
|
if: github.event.ref == 'refs/heads/stable'
|
|
|
|
run: |
|
|
|
|
echo "VERSION=latest" >> $GITHUB_ENV
|
|
|
|
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
|
|
|
|
- name: Extract version (if unstable)
|
|
|
|
if: github.event.ref == 'refs/heads/unstable'
|
|
|
|
run: |
|
|
|
|
echo "VERSION=latest" >> $GITHUB_ENV
|
|
|
|
echo "VERSION_SUFFIX=-unstable" >> $GITHUB_ENV
|
2023-06-05 14:41:11 +00:00
|
|
|
- name: Extract version (if deneb)
|
|
|
|
if: github.event.ref == 'refs/heads/deneb-free-blobs'
|
2022-12-28 16:11:17 +00:00
|
|
|
run: |
|
2023-06-05 14:41:11 +00:00
|
|
|
echo "VERSION=deneb" >> $GITHUB_ENV
|
2022-12-28 16:11:17 +00:00
|
|
|
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
|
2022-01-31 22:55:03 +00:00
|
|
|
- name: Extract version (if tagged release)
|
|
|
|
if: startsWith(github.event.ref, 'refs/tags')
|
|
|
|
run: |
|
|
|
|
echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
|
|
|
|
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
|
2020-12-09 06:06:37 +00:00
|
|
|
outputs:
|
2022-01-31 22:55:03 +00:00
|
|
|
VERSION: ${{ env.VERSION }}
|
|
|
|
VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }}
|
|
|
|
build-docker-single-arch:
|
2023-02-08 02:18:51 +00:00
|
|
|
name: build-docker-${{ matrix.binary }}${{ matrix.features.version_suffix }}
|
2023-08-09 20:15:51 +00:00
|
|
|
# Use self-hosted runners only on the sigp repo.
|
|
|
|
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "large"]') || 'ubuntu-22.04' }}
|
2022-01-31 22:55:03 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
binary: [aarch64,
|
|
|
|
aarch64-portable,
|
|
|
|
x86_64,
|
|
|
|
x86_64-portable]
|
2023-02-08 02:18:51 +00:00
|
|
|
features: [
|
2023-02-13 03:32:03 +00:00
|
|
|
{version_suffix: "", env: "gnosis,slasher-lmdb,slasher-mdbx,jemalloc"},
|
2023-02-15 11:51:46 +00:00
|
|
|
{version_suffix: "-dev", env: "jemalloc,spec-minimal"}
|
2023-02-08 02:18:51 +00:00
|
|
|
]
|
2022-09-29 06:13:33 +00:00
|
|
|
include:
|
|
|
|
- profile: maxperf
|
|
|
|
|
2022-01-31 22:55:03 +00:00
|
|
|
needs: [extract-version]
|
2020-12-11 00:19:35 +00:00
|
|
|
env:
|
2022-01-31 22:55:03 +00:00
|
|
|
VERSION: ${{ needs.extract-version.outputs.VERSION }}
|
|
|
|
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
|
2023-02-08 02:18:51 +00:00
|
|
|
FEATURE_SUFFIX: ${{ matrix.features.version_suffix }}
|
2020-12-09 06:06:37 +00:00
|
|
|
steps:
|
2022-11-13 22:40:44 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-02-15 06:09:54 +00:00
|
|
|
- name: Update Rust
|
2023-08-09 20:15:51 +00:00
|
|
|
if: env.SELF_HOSTED_RUNNERS == false
|
2021-02-15 06:09:54 +00:00
|
|
|
run: rustup update stable
|
2020-12-09 06:06:37 +00:00
|
|
|
- name: Dockerhub login
|
|
|
|
run: |
|
|
|
|
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
|
2022-01-31 22:55:03 +00:00
|
|
|
- name: Cross build Lighthouse binary
|
|
|
|
run: |
|
2021-01-19 03:50:10 +00:00
|
|
|
cargo install cross
|
2023-02-13 03:32:03 +00:00
|
|
|
env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ matrix.features.env }} make build-${{ matrix.binary }}
|
2023-08-09 20:15:51 +00:00
|
|
|
- name: Make bin dir
|
|
|
|
run: mkdir ./bin
|
2022-01-31 22:55:03 +00:00
|
|
|
- name: Move cross-built binary into Docker scope (if ARM)
|
|
|
|
if: startsWith(matrix.binary, 'aarch64')
|
2023-08-09 20:15:51 +00:00
|
|
|
run: mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin
|
2022-01-31 22:55:03 +00:00
|
|
|
- name: Move cross-built binary into Docker scope (if x86_64)
|
|
|
|
if: startsWith(matrix.binary, 'x86_64')
|
2023-08-09 20:15:51 +00:00
|
|
|
run: mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin
|
2022-01-31 22:55:03 +00:00
|
|
|
- name: Map aarch64 to arm64 short arch
|
|
|
|
if: startsWith(matrix.binary, 'aarch64')
|
|
|
|
run: echo "SHORT_ARCH=arm64" >> $GITHUB_ENV
|
|
|
|
- name: Map x86_64 to amd64 short arch
|
|
|
|
if: startsWith(matrix.binary, 'x86_64')
|
|
|
|
run: echo "SHORT_ARCH=amd64" >> $GITHUB_ENV;
|
|
|
|
- name: Set modernity suffix
|
|
|
|
if: endsWith(matrix.binary, '-portable') != true
|
|
|
|
run: echo "MODERNITY_SUFFIX=-modern" >> $GITHUB_ENV;
|
2023-08-10 16:42:56 +00:00
|
|
|
|
|
|
|
- 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: .
|
2023-08-10 17:09:18 +00:00
|
|
|
platforms: linux/${{ env.SHORT_ARCH }}
|
2023-08-10 16:42:56 +00:00
|
|
|
push: true
|
2023-08-10 17:09:18 +00:00
|
|
|
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}${{ env.MODERNITY_SUFFIX }}${{ env.FEATURE_SUFFIX }}
|
2023-08-10 16:42:56 +00:00
|
|
|
|
2020-12-09 06:06:37 +00:00
|
|
|
build-docker-multiarch:
|
2022-01-31 22:55:03 +00:00
|
|
|
name: build-docker-multiarch${{ matrix.modernity }}
|
2022-11-13 22:40:44 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2022-01-31 22:55:03 +00:00
|
|
|
needs: [build-docker-single-arch, extract-version]
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
modernity: ["", "-modern"]
|
2020-12-11 00:19:35 +00:00
|
|
|
env:
|
2022-01-31 22:55:03 +00:00
|
|
|
VERSION: ${{ needs.extract-version.outputs.VERSION }}
|
|
|
|
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
|
2020-12-09 06:06:37 +00:00
|
|
|
steps:
|
2023-08-10 19:51:44 +00:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
|
2020-12-09 06:06:37 +00:00
|
|
|
- name: Dockerhub login
|
|
|
|
run: |
|
|
|
|
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
|
2023-08-10 19:51:44 +00:00
|
|
|
|
2020-12-09 06:06:37 +00:00
|
|
|
- name: Create and push multiarch manifest
|
|
|
|
run: |
|
2023-08-10 19:51:44 +00:00
|
|
|
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 }};
|
|
|
|
|
2021-07-21 03:24:23 +00:00
|
|
|
build-docker-lcli:
|
2022-11-13 22:40:44 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2022-01-31 22:55:03 +00:00
|
|
|
needs: [extract-version]
|
|
|
|
env:
|
|
|
|
VERSION: ${{ needs.extract-version.outputs.VERSION }}
|
|
|
|
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
|
2021-07-21 03:24:23 +00:00
|
|
|
steps:
|
2022-11-13 22:40:44 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-07-21 03:24:23 +00:00
|
|
|
- name: Dockerhub login
|
|
|
|
run: |
|
|
|
|
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
|
|
|
|
- name: Build lcli dockerfile (with push)
|
|
|
|
run: |
|
|
|
|
docker build \
|
|
|
|
--build-arg PORTABLE=true \
|
2022-01-31 22:55:03 +00:00
|
|
|
--tag ${LCLI_IMAGE_NAME}:${VERSION}${VERSION_SUFFIX} \
|
2021-07-21 03:24:23 +00:00
|
|
|
--file ./lcli/Dockerfile .
|
2022-01-31 22:55:03 +00:00
|
|
|
docker push ${LCLI_IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}
|