From 2fbd69059e180592cc8a6a6dc511eeaaa942c1ac Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 14 Jan 2020 15:08:20 +0100 Subject: [PATCH] add multi-arch docker files --- .drone.star | 16 +++++------ .drone.yml | 59 ++++++++++++++++++++++------------------- docker/Dockerfile | 12 --------- docker/Dockerfile.amd64 | 5 ++++ docker/Dockerfile.arm | 5 ++++ docker/Dockerfile.arm64 | 5 ++++ docker/manifest.tmpl | 20 ++++++++++++++ 7 files changed, 74 insertions(+), 48 deletions(-) delete mode 100644 docker/Dockerfile create mode 100644 docker/Dockerfile.amd64 create mode 100644 docker/Dockerfile.arm create mode 100644 docker/Dockerfile.arm64 create mode 100644 docker/manifest.tmpl diff --git a/.drone.star b/.drone.star index e896861..5e0ec9a 100644 --- a/.drone.star +++ b/.drone.star @@ -75,7 +75,7 @@ def linux(arch): return { 'kind': 'pipeline', 'type': 'docker', - 'name': 'linux-%s' % arch, + 'name': 'build-container-%s' % arch, 'platform': { 'os': 'linux', 'arch': arch, @@ -88,7 +88,7 @@ def linux(arch): 'CGO_ENABLED': '0' }, 'commands': [ - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/%s/github-releases-notifier' % arch + 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/%s/github-releases-notifier' % arch ], 'when': { 'event': { @@ -105,7 +105,7 @@ def linux(arch): 'CGO_ENABLED': '0' }, 'commands': [ - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/%s/github-releases-notifier' % arch + 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/%s/github-releases-notifier' % arch ], 'when': { 'event': [ @@ -117,7 +117,7 @@ def linux(arch): 'name': 'executable', 'image': 'golang:1.12', 'commands': [ - './release/linux/%s/github-releases-notifier --help' % arch + './release/%s/github-releases-notifier --help' % arch ] }, { @@ -125,8 +125,8 @@ def linux(arch): 'image': 'plugins/docker', 'settings': { 'dry_run': True, - 'tags': 'linux-%s' % arch, - 'dockerfile': 'docker/Dockerfile.linux.%s' % arch, + 'tags': arch, + 'dockerfile': 'docker/Dockerfile.%s' % arch, 'repo': 'xoxys/github-releases-notifier', 'username': { 'from_secret': 'docker_username' @@ -146,8 +146,8 @@ def linux(arch): 'image': 'plugins/docker', 'settings': { 'auto_tag': True, - 'auto_tag_suffix': 'linux-%s' % arch, - 'dockerfile': 'docker/Dockerfile.linux.%s' % arch, + 'auto_tag_suffix': arch, + 'dockerfile': 'docker/Dockerfile.%s' % arch, 'repo': 'xoxys/github-releases-notifier', 'username': { 'from_secret': 'docker_username' diff --git a/.drone.yml b/.drone.yml index 73b2172..b1516f3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -37,7 +37,7 @@ trigger: --- kind: pipeline type: docker -name: linux-amd64 +name: build-container-amd64 platform: os: linux @@ -47,7 +47,7 @@ steps: - name: build-push image: golang:1.12 commands: - - go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/amd64/github-releases-notifier + - go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/amd64/github-releases-notifier environment: CGO_ENABLED: 0 when: @@ -58,7 +58,7 @@ steps: - name: build-tag image: golang:1.12 commands: - - go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/amd64/github-releases-notifier + - go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/amd64/github-releases-notifier environment: CGO_ENABLED: 0 when: @@ -68,17 +68,17 @@ steps: - name: executable image: golang:1.12 commands: - - ./release/linux/amd64/github-releases-notifier --help + - ./release/amd64/github-releases-notifier --help - name: dryrun image: plugins/docker settings: - dockerfile: docker/Dockerfile.linux.amd64 + dockerfile: docker/Dockerfile.amd64 dry_run: true password: from_secret: docker_password repo: xoxys/github-releases-notifier - tags: linux-amd64 + tags: amd64 username: from_secret: docker_username when: @@ -89,8 +89,8 @@ steps: image: plugins/docker settings: auto_tag: true - auto_tag_suffix: linux-amd64 - dockerfile: docker/Dockerfile.linux.amd64 + auto_tag_suffix: amd64 + dockerfile: docker/Dockerfile.amd64 password: from_secret: docker_password repo: xoxys/github-releases-notifier @@ -113,7 +113,7 @@ depends_on: --- kind: pipeline type: docker -name: linux-arm64 +name: build-container-arm64 platform: os: linux @@ -123,7 +123,7 @@ steps: - name: build-push image: golang:1.12 commands: - - go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/arm64/github-releases-notifier + - go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/arm64/github-releases-notifier environment: CGO_ENABLED: 0 when: @@ -134,7 +134,7 @@ steps: - name: build-tag image: golang:1.12 commands: - - go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/arm64/github-releases-notifier + - go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/arm64/github-releases-notifier environment: CGO_ENABLED: 0 when: @@ -144,17 +144,17 @@ steps: - name: executable image: golang:1.12 commands: - - ./release/linux/arm64/github-releases-notifier --help + - ./release/arm64/github-releases-notifier --help - name: dryrun image: plugins/docker settings: - dockerfile: docker/Dockerfile.linux.arm64 + dockerfile: docker/Dockerfile.arm64 dry_run: true password: from_secret: docker_password repo: xoxys/github-releases-notifier - tags: linux-arm64 + tags: arm64 username: from_secret: docker_username when: @@ -165,8 +165,8 @@ steps: image: plugins/docker settings: auto_tag: true - auto_tag_suffix: linux-arm64 - dockerfile: docker/Dockerfile.linux.arm64 + auto_tag_suffix: arm64 + dockerfile: docker/Dockerfile.arm64 password: from_secret: docker_password repo: xoxys/github-releases-notifier @@ -189,7 +189,7 @@ depends_on: --- kind: pipeline type: docker -name: linux-arm +name: build-container-arm platform: os: linux @@ -199,7 +199,7 @@ steps: - name: build-push image: golang:1.12 commands: - - go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/arm/github-releases-notifier + - go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/arm/github-releases-notifier environment: CGO_ENABLED: 0 when: @@ -210,7 +210,7 @@ steps: - name: build-tag image: golang:1.12 commands: - - go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/arm/github-releases-notifier + - go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/arm/github-releases-notifier environment: CGO_ENABLED: 0 when: @@ -220,17 +220,17 @@ steps: - name: executable image: golang:1.12 commands: - - ./release/linux/arm/github-releases-notifier --help + - ./release/arm/github-releases-notifier --help - name: dryrun image: plugins/docker settings: - dockerfile: docker/Dockerfile.linux.arm + dockerfile: docker/Dockerfile.arm dry_run: true password: from_secret: docker_password repo: xoxys/github-releases-notifier - tags: linux-arm + tags: arm username: from_secret: docker_username when: @@ -241,8 +241,8 @@ steps: image: plugins/docker settings: auto_tag: true - auto_tag_suffix: linux-arm - dockerfile: docker/Dockerfile.linux.arm + auto_tag_suffix: arm + dockerfile: docker/Dockerfile.arm password: from_secret: docker_password repo: xoxys/github-releases-notifier @@ -296,14 +296,17 @@ trigger: ref: - refs/heads/master - refs/tags/** + status: + - success + - failure depends_on: -- linux-amd64 -- linux-arm64 -- linux-arm +- build-container-amd64 +- build-container-arm64 +- build-container-arm --- kind: signature -hmac: 4d1e4e2ae2b63f0a0175b226233cc3694e04068ea8a5899c802de21dfa795999 +hmac: c29f1291ef90ed62fa03a3788fc0e9dc03c9f76adc5adabd3097ee934aa3582b ... diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 9d3a3fa..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM golang:1.8 as builder - -ADD . /go/src/github.com/justwatchcom/github-releases-notifier -WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier - -RUN make build - -FROM alpine:3.6 -RUN apk --no-cache add ca-certificates - -COPY --from=builder /go/src/github.com/justwatchcom/github-releases-notifier /bin/ -ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/docker/Dockerfile.amd64 b/docker/Dockerfile.amd64 new file mode 100644 index 0000000..500e04e --- /dev/null +++ b/docker/Dockerfile.amd64 @@ -0,0 +1,5 @@ +FROM alpine:3.10 +RUN apk --no-cache add ca-certificates + +ADD release/amd64/github-releases-notifier /bin/ +ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/docker/Dockerfile.arm b/docker/Dockerfile.arm new file mode 100644 index 0000000..336663e --- /dev/null +++ b/docker/Dockerfile.arm @@ -0,0 +1,5 @@ +FROM alpine:3.10 +RUN apk --no-cache add ca-certificates + +ADD release/amd/github-releases-notifier /bin/ +ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 new file mode 100644 index 0000000..2a7f0c7 --- /dev/null +++ b/docker/Dockerfile.arm64 @@ -0,0 +1,5 @@ +FROM alpine:3.10 +RUN apk --no-cache add ca-certificates + +ADD release/arm64/github-releases-notifier /bin/ +ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl new file mode 100644 index 0000000..5092452 --- /dev/null +++ b/docker/manifest.tmpl @@ -0,0 +1,20 @@ +image: xoxys/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - image: xoxys/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64 + platform: + architecture: amd64 + os: linux + - image: xoxys/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64 + platform: + architecture: arm64 + os: linux + - image: xoxys/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm + platform: + architecture: arm + os: linux