Add multiarch building from Drone
continuous-integration/drone/push Build is passing Details

This commit is contained in:
IamTheFij 2019-03-07 13:49:06 -08:00
parent 4ddbcff456
commit 52dced87a8
6 changed files with 208 additions and 2 deletions

137
.drone.yml Normal file
View File

@ -0,0 +1,137 @@
kind: pipeline
name: linux-amd64
steps:
- name: get qemu
image: ubuntu:bionic
commands:
- apt-get update
- apt-get install -y make wget
- make build/qemu-x86_64-static
when:
branch:
- master
event:
- push
- tag
- name: build
image: plugins/docker
settings:
repo: iamthefij/cloudflare-ddns
auto_tag: true
auto_tag_suffix: linux-amd64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
branch:
- master
event:
- push
- tag
---
kind: pipeline
name: linux-arm
steps:
- name: get qemu
image: ubuntu:bionic
commands:
- apt-get update
- apt-get install -y make wget
- make build/qemu-arm-static
when:
branch:
- master
event:
- push
- tag
- name: build
image: plugins/docker
settings:
repo: iamthefij/cloudflare-ddns
auto_tag: true
auto_tag_suffix: linux-arm
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- ARCH=arm
- REPO=arm32v6
when:
branch:
- master
event:
- push
- tag
---
kind: pipeline
name: linux-arm64
steps:
- name: get qemu
image: ubuntu:bionic
commands:
- apt-get update
- apt-get install -y make wget
- make build/qemu-aarch64-static
when:
branch:
- master
event:
- push
- tag
- name: build
image: plugins/docker
settings:
repo: iamthefij/cloudflare-ddns
auto_tag: true
auto_tag_suffix: linux-arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- ARCH=aarch64
- REPO=arm64v8
when:
branch:
- master
event:
- push
- tag
---
kind: pipeline
name: manifest
depends_on:
- linux-amd64
- linux-arm
- linux-arm64
steps:
- name: publish manifest
image: plugins/manifest
settings:
spec: manifest.tmpl
auto_tag: true
ignore_missing: true
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
branch:
- master
event:
- push
- tag

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
qemu-*
*.tar.gz
tags

View File

@ -1,4 +1,9 @@
FROM python:3-alpine
ARG REPO=library
FROM ${REPO}/python:3-alpine
ARG ARCH=x86_64
COPY ./build/qemu-${ARCH}-static /usr/bin/
RUN mkdir -p /src
WORKDIR /src

View File

@ -1,16 +1,39 @@
DOCKER_TAG ?= cloudflare-ddns-dev-${USER}
.PHONY: default
default: test
.PHONY:test
test:
@echo ok
.PHONY: update
update:
curl -o update_ddns.py https://raw.githubusercontent.com/cloudflare/python-cloudflare/master/examples/example_update_dynamic_dns.py
chmod +x update_ddns.py
build:
.PHONY: build
build: build/qemu-x86_64-static
docker build . -t ${DOCKER_TAG}
build/qemu-arm-static:
./get_qemu.sh arm
build/qemu-x86_64-static:
./get_qemu.sh x86_64
build/qemu-aarch64-static:
./get_qemu.sh aarch64
.PHONY: cross-build-arm
cross-build-arm: build/qemu-arm-static
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
.PHONY: run
run: build
docker run --rm -e DOMAIN=${DOMAIN} \
-e CF_API_EMAIL=${CF_API_EMAIL} \

13
get_qemu.sh Executable file
View File

@ -0,0 +1,13 @@
#! /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

25
manifest.tmpl Normal file
View File

@ -0,0 +1,25 @@
image: iamthefij/cloudflare-ddns:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
-
image: iamthefij/cloudflare-ddns:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: iamthefij/cloudflare-ddns:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
-
image: iamthefij/cloudflare-ddns:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
variant: v7