From 7182326ac8ec98f3c7dfdf696f2ba4381946588f Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Wed, 24 Feb 2021 08:43:43 -0500 Subject: [PATCH] Add support for multi-arch/arm64 images (#552) * drone Signed-off-by: Joe Elliott * /wave * yaml cleanup Signed-off-by: Joe Elliott * Require arch to image-tags Signed-off-by: Joe Elliott * Revert "Require arch to image-tags" This reverts commit 8143bf47d8a68fc999f05324ffa0d49f9a65c669. * reverse course! image-tag doesn't take arch Signed-off-by: Joe Elliott * changed path Signed-off-by: Joe Elliott * added tags to manifest Signed-off-by: Joe Elliott * fixed path to template Signed-off-by: Joe Elliott * fixed to only support one build tag Signed-off-by: Joe Elliott * reference build tags differently Signed-off-by: Joe Elliott * Linusw Torvalds would not approve Signed-off-by: Joe Elliott * Added readme Signed-off-by: Joe Elliott --- .drone.yml | 85 ---------------- .drone/docker-manifest.tmpl | 13 +++ .drone/drone.yml | 193 ++++++++++++++++++++++++++++++++++++ .drone/readme.md | 34 +++++++ tools/image-tag | 2 +- 5 files changed, 241 insertions(+), 86 deletions(-) delete mode 100644 .drone.yml create mode 100644 .drone/docker-manifest.tmpl create mode 100644 .drone/drone.yml create mode 100644 .drone/readme.md diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 9fad55838ff..00000000000 --- a/.drone.yml +++ /dev/null @@ -1,85 +0,0 @@ ---- -kind: pipeline -name: docker-amd64 - -platform: - os: linux - arch: amd64 - -steps: -- name: image-tag - image: alpine/git - commands: - - git fetch origin --tags - - echo $(./tools/image-tag) > .tags - -- name: build-tempo-binary - image: golang:1.15.3-alpine - commands: - - apk add make git - - COMPONENT=tempo make exe - - COMPONENT=tempo-query make exe - - COMPONENT=tempo-vulture make exe - -- name: build-tempo-image - image: plugins/docker - settings: - dockerfile: cmd/tempo/Dockerfile - repo: grafana/tempo - username: - from_secret: docker_username - password: - from_secret: docker_password - build_args: - - TARGETARCH=amd64 - -- name: build-tempo-query-image - image: plugins/docker - settings: - dockerfile: cmd/tempo-query/Dockerfile - repo: grafana/tempo-query - username: - from_secret: docker_username - password: - from_secret: docker_password - build_args: - - TARGETARCH=amd64 - -- name: build-tempo-vulture-image - image: plugins/docker - settings: - dockerfile: cmd/tempo-vulture/Dockerfile - repo: grafana/tempo-vulture - username: - from_secret: docker_username - password: - from_secret: docker_password - build_args: - - TARGETARCH=amd64 - -trigger: - ref: - - refs/heads/master - - refs/tags/** - ---- -kind: secret -name: docker_username - -get: - path: infra/data/ci/docker_hub - name: username - ---- -kind: secret -name: docker_password - -get: - path: infra/data/ci/docker_hub - name: password - ---- -kind: signature -hmac: 7b4fba65b74d2143b31f7f03d3a1cfbccba6960b0037cee65a7406df9f507370 - -... diff --git a/.drone/docker-manifest.tmpl b/.drone/docker-manifest.tmpl new file mode 100644 index 00000000000..32323adc382 --- /dev/null +++ b/.drone/docker-manifest.tmpl @@ -0,0 +1,13 @@ +image: grafana/{{config.target}} +tags: + - latest + - {{build.tags}} +manifests: + - image: grafana/{{config.target}}:{{build.tags}}-amd64 + platform: + architecture: amd64 + os: linux + - image: grafana/{{config.target}}:{{build.tags}}-arm64 + platform: + architecture: arm64 + os: linux \ No newline at end of file diff --git a/.drone/drone.yml b/.drone/drone.yml new file mode 100644 index 00000000000..0586350d39a --- /dev/null +++ b/.drone/drone.yml @@ -0,0 +1,193 @@ +--- +## AMD64 ## +kind: pipeline +name: docker-amd64 + +platform: + os: linux + arch: amd64 + +steps: +- name: image-tag + image: alpine/git + commands: + - git fetch origin --tags + - echo $(./tools/image-tag)-amd64 > .tags + +# binaries +- name: build-tempo-binaries + image: golang:1.15.3-alpine + commands: + - apk add make git + - COMPONENT=tempo GOARCH=amd64 make exe + - COMPONENT=tempo-query GOARCH=amd64 make exe + - COMPONENT=tempo-vulture GOARCH=amd64 make exe + +# docker images +- name: build-tempo-image + image: plugins/docker + settings: + dockerfile: cmd/tempo/Dockerfile + repo: grafana/tempo + username: + from_secret: docker_username + password: + from_secret: docker_password + build_args: + - TARGETARCH=amd64 + +- name: build-tempo-query-image + image: plugins/docker + settings: + dockerfile: cmd/tempo-query/Dockerfile + repo: grafana/tempo-query + username: + from_secret: docker_username + password: + from_secret: docker_password + build_args: + - TARGETARCH=amd64 + +- name: build-tempo-vulture-image + image: plugins/docker + settings: + dockerfile: cmd/tempo-vulture/Dockerfile + repo: grafana/tempo-vulture + username: + from_secret: docker_username + password: + from_secret: docker_password + build_args: + - TARGETARCH=amd64 + +--- +## ARM64 ## +kind: pipeline +name: docker-arm64 + +platform: + os: linux + arch: arm64 + +steps: +- name: image-tag + image: alpine/git + commands: + - git fetch origin --tags + - echo $(./tools/image-tag)-arm64 > .tags + +# binaries +- name: build-tempo-binaries + image: golang:1.15.3-alpine + commands: + - apk add make git + - COMPONENT=tempo GOARCH=arm64 make exe + - COMPONENT=tempo-query GOARCH=arm64 make exe + - COMPONENT=tempo-vulture GOARCH=arm64 make exe + +# docker images +- name: build-tempo-image + image: plugins/docker + settings: + dockerfile: cmd/tempo/Dockerfile + repo: grafana/tempo + username: + from_secret: docker_username + password: + from_secret: docker_password + build_args: + - TARGETARCH=arm64 + +- name: build-tempo-query-image + image: plugins/docker + settings: + dockerfile: cmd/tempo-query/Dockerfile + repo: grafana/tempo-query + username: + from_secret: docker_username + password: + from_secret: docker_password + build_args: + - TARGETARCH=arm64 + +- name: build-tempo-vulture-image + image: plugins/docker + settings: + dockerfile: cmd/tempo-vulture/Dockerfile + repo: grafana/tempo-vulture + username: + from_secret: docker_username + password: + from_secret: docker_password + build_args: + - TARGETARCH=arm64 + +--- +## MANIFEST ## +kind: pipeline +name: manifest + +platform: + os: linux + arch: amd64 + +steps: +- name: image-tag + image: alpine/git + commands: + - git fetch origin --tags + - echo $(./tools/image-tag) > .tags + +- name: manifest-tempo + image: plugins/manifest + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + spec: .drone/docker-manifest.tmpl + target: tempo + +- name: manifest-tempo-query + image: plugins/manifest + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + spec: .drone/docker-manifest.tmpl + target: tempo-query + +- name: manifest-tempo-vulture + image: plugins/manifest + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + spec: .drone/docker-manifest.tmpl + target: tempo-vulture + +depends_on: +- docker-amd64 +- docker-arm64 + +--- +kind: secret +name: docker_username + +get: + path: infra/data/ci/docker_hub + name: username + +--- +kind: secret +name: docker_password + +get: + path: infra/data/ci/docker_hub + name: password + +--- +kind: signature +hmac: 7b4fba65b74d2143b31f7f03d3a1cfbccba6960b0037cee65a7406df9f507370 \ No newline at end of file diff --git a/.drone/readme.md b/.drone/readme.md new file mode 100644 index 00000000000..13a7e7bfff3 --- /dev/null +++ b/.drone/readme.md @@ -0,0 +1,34 @@ +# Drone + +Drone is used for our building our official dockerhub images. It is broken into 3 +pipelines. Note that none of the pipelines include testing so it's important that +the codebase is otherwise tested when it begins this process. Currently we use GHA +for testing on PR and only build the master branch. + +# Pipelines + +The pipelines are docker-amd64, docker-arm64, and manifest. The two docker pipelines +run concurrently and create images tagged like this: `tempo:-`. e.g. +`tempo-2.3.0-arm64` or `tempo-e2a314-amd64`. The manifest step then creates a manifest +that combines the mentioned images into one multiarch image named as you would expect: +`tempo-2.3.0` or `tempo-e2a314`. + +The documentation on the manifest step is basically non-existent. There's some very +weak documentation in the drone docs, but it's not even worth looking at. To understand +how to use the manifest step I'd recommend looking at the code itself: + +https://github.com/drone-plugins/drone-manifest + +It is a very simple wrapper that takes the configuration options and runs the following +cli tool: + +https://github.com/estesp/manifest-tool + +`docker-manifest.tmpl` is pushed through the standard go templating library with access +to these objects: https://github.com/drone-plugins/drone-manifest/blob/master/plugin.go#L23 + +# Future work + +If we extend this any further we should probably generate drone.yml. It has a lot of +repeated lines that will become difficult to maintain. Currently loki uses a jsonnet file +and we should perhaps follow suit: https://github.com/grafana/loki/blob/master/.drone/drone.jsonnet \ No newline at end of file diff --git a/tools/image-tag b/tools/image-tag index 5c74cbfbd3e..1bfa27df7d1 100755 --- a/tools/image-tag +++ b/tools/image-tag @@ -4,7 +4,7 @@ set -o errexit set -o nounset set -o pipefail -SHA="$(git rev-parse --short HEAD),latest" +SHA="$(git rev-parse --short HEAD)" # If tag, use tag TAG=$( (git describe --exact-match 2> /dev/null || echo "") | sed 's/v//g')