[Enhancement] Improved Pipeline for Multiarch Images and SemVer Tags (#712)

* ci/drone: multiarch images for everything + auto_tagged semver manifests/images
pull/699/head^2
Thorsten Klein 3 years ago committed by GitHub
parent ed7db5daa9
commit b8f9bad879
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 431
      .drone.yml
  2. 12
      Dockerfile
  3. 27
      dind-manifest.tmpl
  4. 27
      manifest.tmpl
  5. 27
      proxy/manifest.tmpl
  6. 27
      tools/manifest.tmpl

@ -103,58 +103,6 @@ steps:
- "refs/tags/*test*" - "refs/tags/*test*"
- "refs/tags/*dev*" - "refs/tags/*dev*"
- name: docker_build_push_dind
image: plugins/docker
environment:
DOCKER_BUILDKIT: "1"
settings:
repo: rancher/k3d
tags:
- latest-dind
- "${DRONE_TAG}-dind"
dockerfile: Dockerfile
target: dind
context: .
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- GIT_TAG_OVERRIDE=${DRONE_TAG}
depends_on:
- lint
- test
- build
when:
event:
- tag
- name: docker_build_push_binary
environment:
DOCKER_BUILDKIT: "1"
image: plugins/docker
settings:
repo: rancher/k3d
tags:
- latest
- "${DRONE_TAG}"
dockerfile: Dockerfile
target: binary-only
context: .
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- GIT_TAG_OVERRIDE=${DRONE_TAG}
depends_on:
- lint
- test
- build
when:
event:
- tag
services: services:
# Starting the docker service to be used by dind # Starting the docker service to be used by dind
- name: docker - name: docker
@ -215,98 +163,163 @@ trigger:
- main - main
--- ---
##################### ###########################
##### k3d-proxy ##### ###### Docker Images ######
##################### ###########################
#
# +++ Docker Images +++
# Tagged using the auto_tag feature of the docker plugin
# See http://plugins.drone.io/drone-plugins/drone-docker/#autotag
# > if event type is `tag`
# > > 1.0.0 produces docker tags 1, 1.0, 1.0.0
# > > 1.0.0-rc.1 produces docker tags 1.0.0-rc.1
# > if event type is `push` and target branch == default branch (main)
# > > tag `latest`
################################
##### Docker Images: amd64 #####
################################
kind: pipeline kind: pipeline
type: docker type: docker
name: proxy_linux_amd64 name: linux_amd64
platform: platform:
os: linux os: linux
arch: amd64 arch: amd64
steps: steps:
- name: build_push
- name: build_push_binary
environment:
DOCKER_BUILDKIT: "1"
image: plugins/docker
settings:
repo: rancher/k3d
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: Dockerfile
target: binary-only
context: .
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- GIT_TAG_OVERRIDE=${DRONE_TAG}
- name: build_push_dind
image: plugins/docker
environment:
DOCKER_BUILDKIT: "1"
settings:
repo: rancher/k3d
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: Dockerfile
target: dind
context: .
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- GIT_TAG_OVERRIDE=${DRONE_TAG}
- ARCH=amd64
- name: build_push_proxy
image: plugins/docker image: plugins/docker
settings: settings:
repo: rancher/k3d-proxy repo: rancher/k3d-proxy
tags: auto_tag: true
- latest-linux-amd64 auto_tag_suffix: linux-amd64
- "${DRONE_TAG}-linux-amd64"
dockerfile: proxy/Dockerfile dockerfile: proxy/Dockerfile
context: proxy/ context: proxy/
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
when:
event: - name: build_push_tools
- tag image: plugins/docker
settings:
repo: rancher/k3d-tools
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: tools/Dockerfile
context: tools/
username:
from_secret: docker_username
password:
from_secret: docker_password
trigger: trigger:
event: event:
- tag - tag # see note at the start of the "Docker Images" section: creates SemVer tagged images using the `auto_tag` option of the docker plugin
- push # `auto_tag` option only creates the `latest` tag if target branch is default branch (i.e. `main`)
depends_on: depends_on:
- main - main
--- ---
################################
##### Docker Images: arm #####
################################
kind: pipeline kind: pipeline
type: docker type: docker
name: proxy_linux_arm name: linux_arm
platform: platform:
os: linux os: linux
arch: arm arch: arm
steps: steps:
- name: build_push - name: build_push_binary
environment:
DOCKER_BUILDKIT: "1"
image: plugins/docker image: plugins/docker
settings: settings:
repo: rancher/k3d-proxy repo: rancher/k3d
tags: auto_tag: true
- latest-linux-arm auto_tag_suffix: linux-arm
- "${DRONE_TAG}-linux-arm" dockerfile: Dockerfile
dockerfile: proxy/Dockerfile target: binary-only
context: proxy/ context: .
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
build_args: build_args:
- ARCH=arm - GIT_TAG_OVERRIDE=${DRONE_TAG}
when:
event:
- tag
trigger:
event:
- tag
depends_on:
- main
---
kind: pipeline
type: docker
name: proxy_linux_arm64
platform: - name: build_push_dind
os: linux image: plugins/docker
arch: arm64 environment:
DOCKER_BUILDKIT: "1"
settings:
repo: rancher/k3d
auto_tag: true
auto_tag_suffix: linux-arm64
dockerfile: Dockerfile
target: dind
context: .
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- GIT_TAG_OVERRIDE=${DRONE_TAG}
- ARCH=arm
steps: - name: build_push_proxy
- name: build_push
image: plugins/docker image: plugins/docker
settings: settings:
repo: rancher/k3d-proxy repo: rancher/k3d-proxy
tags: auto_tag: true
- latest-linux-arm64 auto_tag_suffix: linux-arm
- "${DRONE_TAG}-linux-arm64"
dockerfile: proxy/Dockerfile dockerfile: proxy/Dockerfile
context: proxy/ context: proxy/
username: username:
@ -314,196 +327,184 @@ steps:
password: password:
from_secret: docker_password from_secret: docker_password
build_args: build_args:
- ARCH=arm64 - ARCH=arm
when:
event:
- tag
trigger:
event:
- tag
depends_on:
- main
---
kind: pipeline
type: docker
name: proxy_manifest
platform:
os: linux
arch: amd64
steps: - name: build_push_tools
- name: push_manifest image: plugins/docker
image: plugins/manifest
settings: settings:
repo: rancher/k3d-tools
auto_tag: true
auto_tag_suffix: linux-arm
dockerfile: tools/Dockerfile
context: tools/
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
target: "rancher/k3d-proxy:${DRONE_TAG}"
template: "rancher/k3d-proxy:${DRONE_TAG}-OS-ARCH"
platforms:
- linux/amd64
- linux/arm
- linux/arm64
when:
event:
- tag
trigger: trigger:
event: event:
- tag - tag # see note at the start of the "Docker Images" section: creates SemVer tagged images using the `auto_tag` option of the docker plugin
- push # `auto_tag` option only creates the `latest` tag if target branch is default branch (i.e. `main`)
depends_on: depends_on:
- main - main
- proxy_linux_amd64
- proxy_linux_arm
- proxy_linux_arm64
--- ---
#####################
##### k3d-tools ##### ################################
##################### ##### Docker Images: arm64 #####
################################
kind: pipeline kind: pipeline
type: docker type: docker
name: tools_linux_amd64 name: linux_arm64
platform: platform:
os: linux os: linux
arch: amd64 arch: arm64
steps: steps:
- name: build_push
- name: build_push_binary
environment:
DOCKER_BUILDKIT: "1"
image: plugins/docker image: plugins/docker
settings: settings:
repo: rancher/k3d-tools repo: rancher/k3d
tags: auto_tag: true
- latest-linux-amd64 auto_tag_suffix: linux-arm64
- "${DRONE_TAG}-linux-amd64" dockerfile: Dockerfile
dockerfile: tools/Dockerfile target: binary-only
context: tools/ context: .
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
when: build_args:
event: - GIT_TAG_OVERRIDE=${DRONE_TAG}
- tag
trigger:
event:
- tag
depends_on:
- main
---
kind: pipeline - name: build_push_dind
type: docker image: plugins/docker
name: tools_linux_arm environment:
DOCKER_BUILDKIT: "1"
settings:
repo: rancher/k3d
auto_tag: true
auto_tag_suffix: linux-arm64
dockerfile: Dockerfile
target: dind
context: .
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- GIT_TAG_OVERRIDE=${DRONE_TAG}
- ARCH=arm64
platform: - name: build_push_proxy
os: linux image: plugins/docker
arch: arm settings:
repo: rancher/k3d-proxy
auto_tag: true
auto_tag_suffix: linux-arm64
dockerfile: proxy/Dockerfile
context: proxy/
username:
from_secret: docker_username
password:
from_secret: docker_password
build_args:
- ARCH=arm64
steps: - name: build_push_tools
- name: build_push
image: plugins/docker image: plugins/docker
settings: settings:
repo: rancher/k3d-tools repo: rancher/k3d-tools
tags: auto_tag: true
- latest-linux-arm auto_tag_suffix: linux-arm64
- "${DRONE_TAG}-linux-arm"
dockerfile: tools/Dockerfile dockerfile: tools/Dockerfile
context: tools/ context: tools/
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
when:
event:
- tag
trigger: trigger:
event: event:
- tag - tag # see note at the start of the "Docker Images" section: creates SemVer tagged images using the `auto_tag` option of the docker plugin
- push # `auto_tag` option only creates the `latest` tag if target branch is default branch (i.e. `main`)
depends_on: depends_on:
- main - main
--- ---
##############################
###### Docker Manifests ######
##############################
kind: pipeline kind: pipeline
type: docker type: docker
name: tools_linux_arm64 name: manifests
platform: platform:
os: linux os: linux
arch: arm64 arch: amd64
steps: steps:
- name: build_push - name: push_manifest_binary
image: plugins/docker image: plugins/manifest
settings: settings:
repo: rancher/k3d-tools
tags:
- latest-linux-arm64
- "${DRONE_TAG}-linux-arm64"
dockerfile: tools/Dockerfile
context: tools/
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
when: spec: manifest.tmpl
event: auto_tag: true
- tag ignore_missing: false
trigger:
event:
- tag
depends_on:
- main
---
kind: pipeline - name: push_manifest_dind
type: docker image: plugins/manifest
name: tools_manifest settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
spec: dind-manifest.tmpl
auto_tag: true
ignore_missing: false
platform: - name: push_manifest_proxy
os: linux image: plugins/manifest
arch: amd64 settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
spec: proxy/manifest.tmpl
auto_tag: true
ignore_missing: false
steps: - name: push_manifest_tools
- name: push_manifest
image: plugins/manifest image: plugins/manifest
settings: settings:
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
target: "rancher/k3d-tools:${DRONE_TAG}" spec: tools/manifest.tmpl
template: "rancher/k3d-tools:${DRONE_TAG}-OS-ARCH" auto_tag: true
platforms: ignore_missing: false
- linux/amd64
- linux/arm
- linux/arm64
when:
event:
- tag
trigger: trigger:
event: event:
- tag - tag # see note at the start of the "Docker Images" section: creates SemVer tagged images using the `auto_tag` option of the manifest plugin
- push # `auto_tag` option only creates the `latest` tag if target branch is default branch (i.e. `main`)
depends_on: depends_on:
- main - main
- tools_linux_amd64 - linux_amd64
- tools_linux_arm - linux_arm
- tools_linux_arm64 - linux_arm64

@ -15,16 +15,20 @@ RUN make build -e GIT_TAG_OVERRIDE=${GIT_TAG_OVERRIDE} && bin/k3d version
# -> used e.g. in our CI pipelines for testing # # -> used e.g. in our CI pipelines for testing #
####################################################### #######################################################
FROM docker:20.10-dind as dind FROM docker:20.10-dind as dind
ARG OS=linux
ARG ARCH=amd64
# install some basic packages needed for testing, etc. # install some basic packages needed for testing, etc.
RUN apk update && apk add bash curl sudo jq git make netcat-openbsd RUN echo "building for ${OS}/${ARCH}" && \
apk update && \
apk add bash curl sudo jq git make netcat-openbsd
# install kubectl to interact with the k3d cluster # install kubectl to interact with the k3d cluster
RUN curl -L https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl && \ RUN curl -L https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/${OS}/${ARCH}/kubectl -o /usr/local/bin/kubectl && \
chmod +x /usr/local/bin/kubectl chmod +x /usr/local/bin/kubectl
# install yq (yaml processor) from source, as the busybox yq had some issues # install yq (yaml processor) from source, as the busybox yq had some issues
RUN curl -L https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_linux_amd64 -o /usr/bin/yq &&\ RUN curl -L https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_${OS}_${ARCH} -o /usr/bin/yq &&\
chmod +x /usr/bin/yq chmod +x /usr/bin/yq
COPY --from=builder /app/bin/k3d /bin/k3d COPY --from=builder /app/bin/k3d /bin/k3d
@ -34,4 +38,4 @@ COPY --from=builder /app/bin/k3d /bin/k3d
######################################### #########################################
FROM scratch as binary-only FROM scratch as binary-only
COPY --from=builder /app/bin/k3d /bin/k3d COPY --from=builder /app/bin/k3d /bin/k3d
ENTRYPOINT ["/bin/k3d"] ENTRYPOINT ["/bin/k3d"]

@ -0,0 +1,27 @@
image: rancher/k3d:{{#if build.tag}}{{build.tag}}{{else}}latest{{/if}}dind
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: rancher/k3d:{{#if build.tag}}{{build.tag}}-{{/if}}dind-linux-amd64
platform:
architecture: amd64
os: linux
- image: rancher/k3d:{{#if build.tag}}{{build.tag}}-{{/if}}dind-linux-arm64
platform:
variant: v8
architecture: arm64
os: linux
- image: rancher/k3d:{{#if build.tag}}{{build.tag}}-{{/if}}dind-linux-arm
platform:
variant: v7
architecture: arm
os: linux
- image: rancher/k3d:{{#if build.tag}}{{build.tag}}-{{/if}}dind-linux-arm
platform:
variant: v6
architecture: arm
os: linux

@ -0,0 +1,27 @@
image: rancher/k3d:{{#if build.tag}}{{build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: rancher/k3d:{{#if build.tag}}{{build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: rancher/k3d:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm64
platform:
variant: v8
architecture: arm64
os: linux
- image: rancher/k3d:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm
platform:
variant: v7
architecture: arm
os: linux
- image: rancher/k3d:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm
platform:
variant: v6
architecture: arm
os: linux

@ -0,0 +1,27 @@
image: rancher/k3d-proxy:{{#if build.tag}}{{build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: rancher/k3d-proxy:{{#if build.tag}}{{build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: rancher/k3d-proxy:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm64
platform:
variant: v8
architecture: arm64
os: linux
- image: rancher/k3d-proxy:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm
platform:
variant: v7
architecture: arm
os: linux
- image: rancher/k3d-proxy:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm
platform:
variant: v6
architecture: arm
os: linux

@ -0,0 +1,27 @@
image: rancher/k3d-tools:{{#if build.tag}}{{build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: rancher/k3d-tools:{{#if build.tag}}{{build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: rancher/k3d-tools:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm64
platform:
variant: v8
architecture: arm64
os: linux
- image: rancher/k3d-tools:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm
platform:
variant: v7
architecture: arm
os: linux
- image: rancher/k3d-tools:{{#if build.tag}}{{build.tag}}-{{/if}}linux-arm
platform:
variant: v6
architecture: arm
os: linux
Loading…
Cancel
Save