Improve docker auto builds (#2078)
## Issue Addressed N/A ## Proposed Changes - hardcode `ubuntu-18.04` -- I don't think this was causing us issues, but github actions is in the process of migrating `ubuntu-latest` from Ubuntu 18 -> 20.. so just in case - different source of emulation dependencies -> https://github.com/tonistiigi/binfmt - this one is explicitly referenced in the `buildx` github docs - install emulation dependencies and run `docker buildx` in the same `run` command - enable `buildx` with `DOCKER_CLI_EXPERIMENTAL: enabled` rather than re-building it ## Additional Info N/A Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
parent
1abc70e815
commit
c1e27f4c89
34
.github/workflows/docker.yml
vendored
34
.github/workflows/docker.yml
vendored
@ -13,7 +13,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
extract-branch-name:
|
extract-branch-name:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- name: Extract branch name
|
- name: Extract branch name
|
||||||
run: echo "::set-output name=BRANCH_NAME::$(echo ${GITHUB_REF#refs/heads/})"
|
run: echo "::set-output name=BRANCH_NAME::$(echo ${GITHUB_REF#refs/heads/})"
|
||||||
@ -21,8 +21,11 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
BRANCH_NAME: ${{ steps.extract_branch.outputs.BRANCH_NAME }}
|
BRANCH_NAME: ${{ steps.extract_branch.outputs.BRANCH_NAME }}
|
||||||
build-docker-arm64:
|
build-docker-arm64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-18.04
|
||||||
needs: [extract-branch-name]
|
needs: [extract-branch-name]
|
||||||
|
# We need to enable experimental docker features in order to use `docker buildx`
|
||||||
|
env:
|
||||||
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Dockerhub login
|
- name: Dockerhub login
|
||||||
@ -41,30 +44,22 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir ./bin;
|
mkdir ./bin;
|
||||||
mv ./target/aarch64-unknown-linux-gnu/release/lighthouse ./bin;
|
mv ./target/aarch64-unknown-linux-gnu/release/lighthouse ./bin;
|
||||||
- name: Build Docker Buildx
|
|
||||||
run: |
|
|
||||||
export DOCKER_BUILDKIT=1;
|
|
||||||
docker build --platform=local -o . git://github.com/docker/buildx;
|
|
||||||
mkdir -p ~/.docker/cli-plugins;
|
|
||||||
mv buildx ~/.docker/cli-plugins/docker-buildx;
|
|
||||||
- name: Create Docker Builder
|
|
||||||
run: |
|
|
||||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes;
|
|
||||||
docker context create builder;
|
|
||||||
docker buildx create --use --name lighthouse builder;
|
|
||||||
- name: Set Env
|
- name: Set Env
|
||||||
if: needs.extract-branch-name.outputs.BRANCH_NAME == 'unstable'
|
if: needs.extract-branch-name.outputs.BRANCH_NAME == 'unstable'
|
||||||
run: |
|
run: |
|
||||||
echo "TAG_SUFFIX=-unstable" >> $GITHUB_ENV;
|
echo "TAG_SUFFIX=-unstable" >> $GITHUB_ENV;
|
||||||
|
# Install dependencies for emulation. Have to create a new builder to pick up emulation support.
|
||||||
- name: Build ARM64 dockerfile (with push)
|
- name: Build ARM64 dockerfile (with push)
|
||||||
run: |
|
run: |
|
||||||
|
docker run --privileged --rm tonistiigi/binfmt --install arm64
|
||||||
|
docker buildx create --use --name cross-builder
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform=linux/arm64 \
|
--platform=linux/arm64 \
|
||||||
--output "type=image,push=true" \
|
|
||||||
--file ./Dockerfile.cross . \
|
--file ./Dockerfile.cross . \
|
||||||
--tag ${IMAGE_NAME}:latest-arm64${TAG_SUFFIX}
|
--tag ${IMAGE_NAME}:latest-arm64${TAG_SUFFIX} \
|
||||||
|
--push
|
||||||
build-docker-amd64:
|
build-docker-amd64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-18.04
|
||||||
needs: [extract-branch-name]
|
needs: [extract-branch-name]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -83,8 +78,11 @@ jobs:
|
|||||||
--file ./Dockerfile .
|
--file ./Dockerfile .
|
||||||
docker push ${IMAGE_NAME}:latest-amd64${TAG_SUFFIX}
|
docker push ${IMAGE_NAME}:latest-amd64${TAG_SUFFIX}
|
||||||
build-docker-multiarch:
|
build-docker-multiarch:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-18.04
|
||||||
needs: [build-docker-arm64, build-docker-amd64, extract-branch-name]
|
needs: [build-docker-arm64, build-docker-amd64, extract-branch-name]
|
||||||
|
# We need to enable experimental docker features in order to use `docker manifest`
|
||||||
|
env:
|
||||||
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
||||||
steps:
|
steps:
|
||||||
- name: Dockerhub login
|
- name: Dockerhub login
|
||||||
run: |
|
run: |
|
||||||
@ -94,9 +92,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "TAG_SUFFIX=-unstable" >> $GITHUB_ENV;
|
echo "TAG_SUFFIX=-unstable" >> $GITHUB_ENV;
|
||||||
- name: Create and push multiarch manifest
|
- name: Create and push multiarch manifest
|
||||||
# We need to enable experimental docker features in order to use `docker manifest`
|
|
||||||
run: |
|
run: |
|
||||||
export DOCKER_CLI_EXPERIMENTAL=enabled;
|
|
||||||
docker manifest create ${IMAGE_NAME}:latest${TAG_SUFFIX} \
|
docker manifest create ${IMAGE_NAME}:latest${TAG_SUFFIX} \
|
||||||
--amend ${IMAGE_NAME}:latest-arm64${TAG_SUFFIX} \
|
--amend ${IMAGE_NAME}:latest-arm64${TAG_SUFFIX} \
|
||||||
--amend ${IMAGE_NAME}:latest-amd64${TAG_SUFFIX};
|
--amend ${IMAGE_NAME}:latest-amd64${TAG_SUFFIX};
|
||||||
|
Loading…
Reference in New Issue
Block a user