From a85013bb78a1d242948f9e2845029eb1cca2b37b Mon Sep 17 00:00:00 2001 From: surtur Date: Wed, 6 Jan 2021 01:49:03 +0100 Subject: [PATCH] feat: enable drone ci builds + add img metadata * also add build status badges to README * add metadata to the image at build time using a build hook --- .drone.yml | 29 +++++++++++++++++++++++++++++ Dockerfile | 7 +++++++ README.md | 3 +++ curl.it | 7 +++++++ hooks/build | 10 ++++++++++ 5 files changed, 56 insertions(+) create mode 100644 .drone.yml create mode 100755 curl.it create mode 100644 hooks/build diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..41e4848 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,29 @@ +--- +kind: pipeline +name: dockerhub-build-trigger + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +trigger: + branch: + - master + event: + - push + - cron + +steps: +- name: call webhook + pull: always + image: bash:latest + environment: + ENDPOINT: + from_secret: DOCKERHUB_ENDPOINT + commands: + - apk add --no-cache curl + - curl -sO https://git.dotya.ml/${DRONE_REPO}/raw/branch/master/curl.it + - bash ./curl.it $ENDPOINT diff --git a/Dockerfile b/Dockerfile index 72bd8fd..d68627e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,12 @@ FROM frolvlad/alpine-java:jdk8-full as build MAINTAINER wanderer +ARG BUILD_DATE +ARG VCS_REF + +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.vcs-url="https://git.dotya.ml/wanderer/docker-alpine-android.git" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.license=GPL-3.0 ENV VERSION_SDK_TOOLS "3859397" ENV VERSION_TOOLS "6609375" diff --git a/README.md b/README.md index 83cda42..ea347af 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # docker-alpine-android +[![Build Status](https://drone.dotya.ml/api/badges/wanderer/docker-alpine-android/status.svg)](https://drone.dotya.ml/wanderer/docker-alpine-android) +[![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/immawanderer/alpine-android)](https://hub.docker.com/r/immawanderer/alpine-android/builds) + push mirror lives in [this GitHub repo](https://github.com/wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf/docker-alpine-android)
development happens on [this Gitea instance](https://git.dotya.ml/wanderer/docker-alpine-android) diff --git a/curl.it b/curl.it new file mode 100755 index 0000000..bd2b744 --- /dev/null +++ b/curl.it @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ $# -gt 1 ]; then + curl -s -H 'Content-Type: application/json' --data '{"docker_tag":"nightly"}' -X POST $2 +else + curl -s -H 'Content-Type: application/json' --data '{"docker_tag":"latest"}' -X POST $1 +fi diff --git a/hooks/build b/hooks/build new file mode 100644 index 0000000..4c69a76 --- /dev/null +++ b/hooks/build @@ -0,0 +1,10 @@ +#!/bin/bash + +# as per https://github.com/rossf7/label-schema-automated-build + +# $IMAGE_NAME var is injected into the build so the tag is correct. + +echo "Build hook running" +docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg VCS_REF=`git rev-parse --short HEAD` \ + -t $IMAGE_NAME .