Update example to show a more realistic implementation

This commit is contained in:
IamTheFij 2019-06-04 17:18:25 -07:00
parent 195809e43c
commit 51323bdde3
4 changed files with 109 additions and 34 deletions

View File

@ -1,13 +1,38 @@
kind: pipeline kind: pipeline
name: linux-amd64 name: tests
trigger:
event:
- push
- tag
steps: steps:
- name: get qemu - name: run tests
image: ubuntu:bionic image: ubuntu:bionic
commands: commands:
- apt-get update - apt-get update
- apt-get install -y make wget - apt-get install -y make
- make build/qemu-x86_64-static - make test
---
kind: pipeline
name: linux-amd64
depends_on:
- tests
trigger:
branch:
- master
event:
- push
- tag
steps:
- name: get qemu
image: busybox
commands:
- ./get_qemu.sh x86_64
- name: build - name: build
image: plugins/docker image: plugins/docker
@ -24,13 +49,21 @@ steps:
kind: pipeline kind: pipeline
name: linux-arm name: linux-arm
depends_on:
- tests
trigger:
branch:
- master
event:
- push
- tag
steps: steps:
- name: get qemu - name: get qemu
image: ubuntu:bionic image: busybox
commands: commands:
- apt-get update - ./get_qemu.sh arm
- apt-get install -y make wget
- make build/qemu-arm-static
- name: build - name: build
image: plugins/docker image: plugins/docker
@ -46,6 +79,40 @@ steps:
- ARCH=arm - ARCH=arm
- REPO=arm32v6 - REPO=arm32v6
---
kind: pipeline
name: linux-arm64
depends_on:
- tests
trigger:
branch:
- master
event:
- push
- tag
steps:
- name: get qemu
image: busybox
commands:
- ./get_qemu.sh arm64
- name: build
image: plugins/docker
settings:
repo: iamthefij/multiarch-pipeline-test
auto_tag: true
auto_tag_suffix: linux-arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- ARCH=arm64
- REPO=arm64v8
--- ---
kind: pipeline kind: pipeline
name: manifest name: manifest
@ -53,6 +120,14 @@ name: manifest
depends_on: depends_on:
- linux-amd64 - linux-amd64
- linux-arm - linux-arm
- linux-arm64
trigger:
branch:
- master
event:
- push
- tag
steps: steps:
- name: publish manifest - name: publish manifest

View File

@ -7,27 +7,40 @@ default: test
test: test:
@echo ok @echo ok
.PHONY: build # Targets to download required qemu binaries for running on an amd64 machine
build: build/qemu-x86_64-static build/qemu-x86_64-static:
docker build . -t ${DOCKER_TAG} ./get_qemu.sh x86_64
build/qemu-arm-static: build/qemu-arm-static:
./get_qemu2.sh arm ./get_qemu.sh arm
build/qemu-x86_64-static:
./get_qemu2.sh x86_64
build/qemu-aarch64-static: build/qemu-aarch64-static:
./get_qemu2.sh aarch64 ./get_qemu.sh aarch64
# Build Docker image for host architechture (amd64)
.PHONY: build
build: build/qemu-x86_64-static
docker build . -t ${DOCKER_TAG}-linux-amd64
# Cross build for arm architechtures
.PHONY: cross-build-arm .PHONY: cross-build-arm
cross-build-arm: build/qemu-arm-static cross-build-arm: build/qemu-arm-static
docker build --build-arg REPO=arm32v6 --build-arg ARCH=arm . -t ${DOCKER_TAG}-arm32v6 docker build --build-arg REPO=arm32v6 --build-arg ARCH=arm . -t ${DOCKER_TAG}-linux-arm
.PHONY: cross-build-arm
cross-build-arm64: build/qemu-aarch64-static
docker build --build-arg REPO=arm64v8 --build-arg ARCH=aarch64 . -t ${DOCKER_TAG}-linux-arm64
# Run on host architechture
.PHONY: run .PHONY: run
run: build run: build
docker run ${DOCKER_TAG} docker run ${DOCKER_TAG}-linux-amd64
.PHONY: run # Cross run on host architechture
.PHONY: cross-run-arm
cross-run-arm: cross-build-arm cross-run-arm: cross-build-arm
docker run --rm ${DOCKER_TAG}-arm32v6 docker run --rm ${DOCKER_TAG}-linux-arm
.PHONY: cross-run-arm64
cross-run-arm64: cross-build-arm64
docker run --rm ${DOCKER_TAG}-linux-arm64

View File

@ -6,7 +6,7 @@ VERSION=v2.9.1-1
mkdir -p build mkdir -p build
cd build cd build
for target_arch in aarch64 arm x86_64; do for target_arch in $*; do
wget -N https://github.com/multiarch/qemu-user-static/releases/download/$VERSION/${HOST_ARCH}_qemu-${target_arch}-static.tar.gz wget -N https://github.com/multiarch/qemu-user-static/releases/download/$VERSION/${HOST_ARCH}_qemu-${target_arch}-static.tar.gz
tar -xvf ${HOST_ARCH}_qemu-${target_arch}-static.tar.gz tar -xvf ${HOST_ARCH}_qemu-${target_arch}-static.tar.gz
rm ${HOST_ARCH}_qemu-${target_arch}-static.tar.gz rm ${HOST_ARCH}_qemu-${target_arch}-static.tar.gz

View File

@ -1,13 +0,0 @@
#! /bin/bash
HOST_ARCH=x86_64
VERSION=v2.9.1-1
mkdir -p build
cd build
for target_arch in $*; do
wget -N https://github.com/multiarch/qemu-user-static/releases/download/$VERSION/${HOST_ARCH}_qemu-${target_arch}-static.tar.gz
tar -xvf ${HOST_ARCH}_qemu-${target_arch}-static.tar.gz
rm ${HOST_ARCH}_qemu-${target_arch}-static.tar.gz
done