Browse Source

Merge #300

300: Fix docker image build r=bonomat a=bonomat

The new task does a few things:
1. Having an extra build target makes the workflow file cleaner
2. it downloads the release targets which we want to build docker images for
3. it extracts the tar files into sub folders. We need to extract into sub folders to so that our image can fine the binaries. By providing `platform` to `docker buildx` the variable `TARGETPLATFORM` will be available when building the image. This variable is either `linux/amd64/`, `linux/arm64/` or `linux/arm/v7`. Hence we need to extract into subfolders.
4. We create 2 images, one for the maker and one for the taker. The images are then pushed to our organisation's docker registry.

Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
refactor/no-log-handler
bors[bot] 3 years ago
committed by GitHub
parent
commit
86f20a12d2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 67
      .github/workflows/build-release-binary.yml
  2. 6
      Dockerfile

67
.github/workflows/build-release-binary.yml

@ -14,52 +14,42 @@ jobs:
target: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
archive_ext: tar archive_ext: tar
docker_platforms: linux/amd64
- bin: taker - bin: taker
target: armv7-unknown-linux-gnueabihf target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest os: ubuntu-latest
archive_ext: tar archive_ext: tar
docker_platforms: linux/arm/v7
- bin: taker - bin: taker
target: aarch64-unknown-linux-gnu target: aarch64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
archive_ext: tar archive_ext: tar
docker_platforms: linux/arm64
- bin: taker - bin: taker
target: x86_64-apple-darwin target: x86_64-apple-darwin
os: macos-latest os: macos-latest
archive_ext: tar archive_ext: tar
docker_platforms: None
- bin: taker - bin: taker
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
os: windows-latest os: windows-latest
archive_ext: zip archive_ext: zip
docker_platforms: None
- bin: maker - bin: maker
target: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
archive_ext: tar archive_ext: tar
docker_platforms: linux/amd64
- bin: maker - bin: maker
target: armv7-unknown-linux-gnueabihf target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest os: ubuntu-latest
archive_ext: tar archive_ext: tar
docker_platforms: linux/arm64
- bin: maker - bin: maker
target: aarch64-unknown-linux-gnu target: aarch64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
archive_ext: tar archive_ext: tar
docker_platforms: linux/arm64
- bin: maker - bin: maker
target: x86_64-apple-darwin target: x86_64-apple-darwin
os: macos-latest os: macos-latest
archive_ext: tar archive_ext: tar
docker_platforms: None
- bin: maker - bin: maker
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
os: windows-latest os: windows-latest
archive_ext: zip archive_ext: zip
docker_platforms: None
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout tagged commit - name: Checkout tagged commit
@ -155,28 +145,65 @@ jobs:
asset_name: ${{ steps.create-archive-name.outputs.archive }} asset_name: ${{ steps.create-archive-name.outputs.archive }}
asset_content_type: application/gzip asset_content_type: application/gzip
build_docker_image:
needs: build_binaries
name: Build docker images
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout tagged commit
uses: actions/checkout@v2.3.4
with:
ref: ${{ github.event.release.target_commitish }}
- name: Set up QEMU - name: Set up QEMU
if: matrix.os != 'windows-latest' && matrix.os != 'macos-latest'
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up docker buildx
if: matrix.os != 'windows-latest' && matrix.os != 'macos-latest'
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Login into github registry - name: Login into github registry
uses: docker/login-action@v1.10.0 uses: docker/login-action@v1.10.0
if: matrix.os != 'windows-latest' && matrix.os != 'macos-latest'
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish docker image - name: Build and publish docker images
if: matrix.os != 'windows-latest' && matrix.os != 'macos-latest'
run: | run: |
gh release download ${{ github.event.release.tag_name }} -p '*Linux_x86_64*' -p '*aarch64*' -p '*armv7*'
# We need to extract into sub folders to so that our dockerimage can fine the binaries.
#
# By providing `platform` to `docker buildx` the variable `TARGETPLATFORM` will be available
# when building the image. This variable is either
# `linux/amd64/`, `linux/arm64/` or `linux/arm/v7`. Hence we need to extract into subfolders.
7z x maker_${{ github.event.release.tag_name }}_Linux_aarch64.tar -olinux/arm64/
7z x taker_${{ github.event.release.tag_name }}_Linux_aarch64.tar -olinux/arm64/
7z x maker_${{ github.event.release.tag_name }}_Linux_x86_64.tar -olinux/amd64/
7z x taker_${{ github.event.release.tag_name }}_Linux_x86_64.tar -olinux/amd64/
7z x maker_${{ github.event.release.tag_name }}_Linux_armv7.tar -olinux/arm/v7
7z x taker_${{ github.event.release.tag_name }}_Linux_armv7.tar -olinux/arm/v7
docker buildx build \ docker buildx build \
--push \ --push \
--platform=${{ matrix.docker_platforms }} \ --platform linux/amd64,linux/arm64,linux/arm/v7 \
--tag ghcr.io/${{ github.actor }}/hermes-${{ matrix.bin }}-${{ matrix.target }} \ --label "org.opencontainers.image.source https://github.com/${{ github.repository }}" \
--build-arg BINARY_PATH=target/${{ matrix.target }}/release/${{ matrix.bin }} \ --tag ghcr.io/${{ github.repository }}/maker:${{ github.event.release.tag_name }} \
--build-arg BINARY_PATH=maker \
. .
docker buildx build \
--push \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--label "org.opencontainers.image.source https://github.com/${{ github.repository }}" \
--tag ghcr.io/${{ github.repository }}/taker:${{ github.event.release.tag_name }} \
--build-arg BINARY_PATH=taker \
.

6
Dockerfile

@ -1,9 +1,11 @@
FROM debian:bullseye-slim FROM debian:bullseye-slim
ARG TARGETPLATFORM
ARG BINARY_PATH ARG BINARY_PATH
RUN echo "Copying $BINARY_PATH into container"
COPY $BINARY_PATH hermes RUN echo "Copying $TARGETPLATFORM/$BINARY_PATH into container"
COPY $TARGETPLATFORM/$BINARY_PATH hermes
RUN chmod a+x hermes RUN chmod a+x hermes

Loading…
Cancel
Save