use buildx to build multi arch images
This commit is contained in:
parent
bbb2700a75
commit
0321580250
6 changed files with 34 additions and 80 deletions
32
.github/workflows/docker-images.yml
vendored
Normal file
32
.github/workflows/docker-images.yml
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
name: Build docker images
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- next
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# https://github.com/docker/setup-qemu-action
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
# https://github.com/docker/setup-buildx-action
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
|
||||||
|
- name: login to docker hub
|
||||||
|
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||||
|
|
||||||
|
- name: build the image
|
||||||
|
run: |
|
||||||
|
docker buildx build --push \
|
||||||
|
--tag edenhaus/bumper:latest \
|
||||||
|
--platform linux/amd64,linux/arm/v7,linux/arm64 .
|
||||||
24
Dockerfile
24
Dockerfile
|
|
@ -1,26 +1,6 @@
|
||||||
ARG FROM_ARCH=amd64
|
ARG ARCH=amd64
|
||||||
|
|
||||||
FROM alpine as builder
|
FROM $ARCH/python:3.8-alpine
|
||||||
|
|
||||||
# Download QEMU, see https://github.com/ckulka/docker-multi-arch-example
|
|
||||||
ADD https://github.com/balena-io/qemu/releases/download/v3.0.0%2Bresin/qemu-3.0.0+resin-arm.tar.gz .
|
|
||||||
RUN tar zxvf qemu-3.0.0+resin-arm.tar.gz --strip-components 1
|
|
||||||
ADD https://github.com/balena-io/qemu/releases/download/v3.0.0%2Bresin/qemu-3.0.0+resin-aarch64.tar.gz .
|
|
||||||
RUN tar zxvf qemu-3.0.0+resin-aarch64.tar.gz --strip-components 1
|
|
||||||
|
|
||||||
FROM $FROM_ARCH/python:3.7-alpine as base
|
|
||||||
|
|
||||||
# Add QEMU
|
|
||||||
# Add QEMU
|
|
||||||
COPY --from=builder qemu-arm-static /usr/bin
|
|
||||||
COPY --from=builder qemu-aarch64-static /usr/bin
|
|
||||||
|
|
||||||
FROM base as builderfinal
|
|
||||||
|
|
||||||
# add build utils (gcc, others)
|
|
||||||
RUN apk add build-base
|
|
||||||
|
|
||||||
FROM base
|
|
||||||
|
|
||||||
COPY requirements.txt /requirements.txt
|
COPY requirements.txt /requirements.txt
|
||||||
|
|
||||||
|
|
|
||||||
10
hooks/build
10
hooks/build
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Custom build script to build images for all supported architectures.
|
|
||||||
# Example for IMAGE_NAME: ckulka/baikal:apache
|
|
||||||
|
|
||||||
for arch in amd64 arm32v7 arm64v8
|
|
||||||
do
|
|
||||||
echo "Building $IMAGE_NAME-$arch"
|
|
||||||
docker build --build-arg FROM_ARCH=$arch --file $DOCKERFILE_PATH --tag $IMAGE_NAME-$arch .
|
|
||||||
done
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Use manifest-tool to create the manifest, given the experimental
|
|
||||||
# "docker manifest" command isn't available yet on Docker Hub.
|
|
||||||
curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-amd64
|
|
||||||
chmod +x manifest-tool
|
|
||||||
|
|
||||||
# Generate the manifest file.
|
|
||||||
# Parameter 1 is the multi-arch image name, e.g. ckulka/baikal:0.5.1
|
|
||||||
# Parameter 2 is the base-image for the variants, e.g. ckulka/baikal:0.5.1-apache
|
|
||||||
function generate_manifest {
|
|
||||||
cat > manifest-generated.yaml << EOF
|
|
||||||
image: $1
|
|
||||||
manifests:
|
|
||||||
- image: $2-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: linux
|
|
||||||
- image: $2-arm32v7
|
|
||||||
platform:
|
|
||||||
architecture: arm
|
|
||||||
os: linux
|
|
||||||
variant: v7
|
|
||||||
- image: $2-arm64v8
|
|
||||||
platform:
|
|
||||||
architecture: arm64
|
|
||||||
os: linux
|
|
||||||
variant: v8
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Pushing multi-arch manifest $IMAGE_NAME"
|
|
||||||
generate_manifest $IMAGE_NAME $IMAGE_NAME
|
|
||||||
./manifest-tool push from-spec manifest-generated.yaml
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Register qemu-*-static for all supported processors except the
|
|
||||||
# current one, but also remove all registered binfmt_misc before
|
|
||||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Custom build script to push images for all supported architectures.
|
|
||||||
|
|
||||||
for arch in amd64 arm32v7 arm64v8
|
|
||||||
do
|
|
||||||
echo "Pushing $IMAGE_NAME-$arch"
|
|
||||||
docker push $IMAGE_NAME-$arch
|
|
||||||
done
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue