diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..0745922 --- /dev/null +++ b/.drone.yml @@ -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 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b4ef05f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +qemu-* +*.tar.gz +tags diff --git a/Dockerfile b/Dockerfile index 846d482..b7ba5f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index 870c3b1..506873c 100644 --- a/Makefile +++ b/Makefile @@ -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} \ diff --git a/get_qemu.sh b/get_qemu.sh new file mode 100755 index 0000000..9ea3b81 --- /dev/null +++ b/get_qemu.sh @@ -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 diff --git a/manifest.tmpl b/manifest.tmpl new file mode 100644 index 0000000..c2e4da5 --- /dev/null +++ b/manifest.tmpl @@ -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