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
name: linux-amd64
name: tests
trigger:
event:
- push
- tag
steps:
- name: get qemu
- name: run tests
image: ubuntu:bionic
commands:
- apt-get update
- apt-get install -y make wget
- make build/qemu-x86_64-static
- apt-get install -y make
- 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
image: plugins/docker
@ -24,13 +49,21 @@ steps:
kind: pipeline
name: linux-arm
depends_on:
- tests
trigger:
branch:
- master
event:
- push
- tag
steps:
- name: get qemu
image: ubuntu:bionic
image: busybox
commands:
- apt-get update
- apt-get install -y make wget
- make build/qemu-arm-static
- ./get_qemu.sh arm
- name: build
image: plugins/docker
@ -46,6 +79,40 @@ steps:
- ARCH=arm
- 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
name: manifest
@ -53,6 +120,14 @@ name: manifest
depends_on:
- linux-amd64
- linux-arm
- linux-arm64
trigger:
branch:
- master
event:
- push
- tag
steps:
- name: publish manifest

View File

@ -7,27 +7,40 @@ default: test
test:
@echo ok
.PHONY: build
build: build/qemu-x86_64-static
docker build . -t ${DOCKER_TAG}
# Targets to download required qemu binaries for running on an amd64 machine
build/qemu-x86_64-static:
./get_qemu.sh x86_64
build/qemu-arm-static:
./get_qemu2.sh arm
build/qemu-x86_64-static:
./get_qemu2.sh x86_64
./get_qemu.sh arm
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
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
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
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
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
tar -xvf ${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