2020-12-09 06:06:37 +00:00
|
|
|
name: docker
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- unstable
|
|
|
|
- stable
|
2022-12-15 00:42:35 +00:00
|
|
|
- capella
|
2022-01-31 22:55:03 +00:00
|
|
|
tags:
|
|
|
|
- v*
|
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
|
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
|
2022-12-15 00:42:35 +00:00
|
|
|
- name: Extract version (if capella)
|
|
|
|
if: github.event.ref == 'refs/heads/capella'
|
|
|
|
run: |
|
|
|
|
echo "VERSION=capella" >> $GITHUB_ENV
|
|
|
|
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:
|
|
|
|
name: build-docker-${{ matrix.binary }}
|
2022-11-13 22:40:44 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2022-01-31 22:55:03 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
binary: [aarch64,
|
|
|
|
aarch64-portable,
|
|
|
|
x86_64,
|
|
|
|
x86_64-portable]
|
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
|
|
|
# We need to enable experimental docker features in order to use `docker buildx`
|
2020-12-11 00:19:35 +00:00
|
|
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
2022-01-31 22:55:03 +00:00
|
|
|
VERSION: ${{ needs.extract-version.outputs.VERSION }}
|
|
|
|
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
|
2023-01-12 04:15:08 +00:00
|
|
|
CROSS_FEATURES: null
|
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
|
|
|
|
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
|
2022-09-29 06:13:33 +00:00
|
|
|
env CROSS_PROFILE=${{ matrix.profile }} make build-${{ matrix.binary }}
|
2022-01-31 22:55:03 +00:00
|
|
|
- name: Move cross-built binary into Docker scope (if ARM)
|
|
|
|
if: startsWith(matrix.binary, 'aarch64')
|
2020-12-09 06:06:37 +00:00
|
|
|
run: |
|
|
|
|
mkdir ./bin;
|
2022-09-29 06:13:33 +00:00
|
|
|
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')
|
2020-12-09 06:06:37 +00:00
|
|
|
run: |
|
2022-01-31 22:55:03 +00:00
|
|
|
mkdir ./bin;
|
2022-09-29 06:13:33 +00:00
|
|
|
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;
|
2020-12-11 00:19:35 +00:00
|
|
|
# Install dependencies for emulation. Have to create a new builder to pick up emulation support.
|
2022-01-31 22:55:03 +00:00
|
|
|
- name: Build Dockerfile and push
|
2020-12-09 06:06:37 +00:00
|
|
|
run: |
|
2022-01-31 22:55:03 +00:00
|
|
|
docker run --privileged --rm tonistiigi/binfmt --install ${SHORT_ARCH}
|
2020-12-11 00:19:35 +00:00
|
|
|
docker buildx create --use --name cross-builder
|
2020-12-09 06:06:37 +00:00
|
|
|
docker buildx build \
|
2022-01-31 22:55:03 +00:00
|
|
|
--platform=linux/${SHORT_ARCH} \
|
2020-12-09 06:06:37 +00:00
|
|
|
--file ./Dockerfile.cross . \
|
2022-01-31 22:55:03 +00:00
|
|
|
--tag ${IMAGE_NAME}:${VERSION}-${SHORT_ARCH}${VERSION_SUFFIX}${MODERNITY_SUFFIX} \
|
2023-01-20 20:26:32 +00:00
|
|
|
--provenance=false \
|
2020-12-11 00:19:35 +00:00
|
|
|
--push
|
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
|
|
|
# We need to enable experimental docker features in order to use `docker manifest`
|
2020-12-11 00:19:35 +00:00
|
|
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
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:
|
|
|
|
- name: Dockerhub login
|
|
|
|
run: |
|
|
|
|
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
|
|
|
|
- name: Create and push multiarch manifest
|
|
|
|
run: |
|
2022-01-31 22:55:03 +00:00
|
|
|
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 }}
|
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}
|