Created
August 5, 2021 15:22
-
-
Save ondrejmo/2cf8e1a6d9b016a95a5b440cd926b6fd to your computer and use it in GitHub Desktop.
multi-architecture docker pipeline in Drone CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
kind: pipeline | |
type: docker | |
name: linux-amd64 | |
trigger: | |
branch: | |
- myapp | |
event: | |
- push | |
- custom | |
platform: | |
arch: amd64 | |
os: linux | |
clone: | |
skip_verify: yes | |
steps: | |
- name: build | |
image: docker:20-dind | |
volumes: | |
- name: dockersock | |
path: /var/run | |
commands: | |
- sleep 5 # give docker enough time to start | |
- docker build --network host -t registry.local:5000/myapp:${DRONE_COMMIT_SHA:0:8}-linux-amd64 . | |
- name: push | |
image: docker:20-dind | |
volumes: | |
- name: dockersock | |
path: /var/run | |
commands: | |
- docker push registry.local:5000/myapp:${DRONE_COMMIT_SHA:0:8}-linux-amd64 | |
services: | |
- name: docker | |
image: docker:20-dind | |
privileged: true | |
entrypoint: | |
- "dockerd" | |
volumes: | |
- name: dockersock | |
path: /var/run | |
command: | |
- "--host=unix:///var/run/docker.sock" | |
- "--insecure-registry=registry.local:5000" | |
volumes: | |
- name: dockersock | |
temp: {} | |
--- | |
kind: pipeline | |
type: docker | |
name: linux-arm64 | |
trigger: | |
branch: | |
- myapp | |
event: | |
- push | |
- custom | |
platform: | |
arch: arm64 | |
os: linux | |
clone: | |
skip_verify: yes | |
steps: | |
- name: build | |
image: docker:20-dind | |
volumes: | |
- name: dockersock | |
path: /var/run | |
commands: | |
- sleep 5 # give docker enough time to start | |
- docker build --network host -t registry.local:5000/${DRONE_COMMIT_BRANCH}:${DRONE_COMMIT_SHA:0:8}-linux-arm64 . | |
- name: push | |
image: docker:20-dind | |
volumes: | |
- name: dockersock | |
path: /var/run | |
commands: | |
- docker push registry.local:5000/${DRONE_COMMIT_BRANCH}:${DRONE_COMMIT_SHA:0:8}-linux-arm64 | |
services: | |
- name: docker | |
image: docker:20-dind | |
privileged: true | |
entrypoint: | |
- "dockerd" | |
volumes: | |
- name: dockersock | |
path: /var/run | |
command: | |
- "--host=unix:///var/run/docker.sock" | |
- "--insecure-registry=registry.local:5000" | |
volumes: | |
- name: dockersock | |
temp: {} | |
--- | |
kind: pipeline | |
type: docker | |
name: manifest | |
trigger: | |
branch: | |
- myapp | |
event: | |
- push | |
- custom | |
clone: | |
skip_verify: yes | |
steps: | |
- name: create && push | |
image: docker:20-dind | |
volumes: | |
- name: dockersock | |
path: /var/run | |
commands: | |
- sleep 5 # give docker enough time to start | |
- docker manifest create --insecure registry.local:5000/${DRONE_COMMIT_BRANCH}:${DRONE_COMMIT_SHA:0:8} --amend registry.local:5000/${DRONE_COMMIT_BRANCH}:${DRONE_COMMIT_SHA:0:8}-linux-amd64 --amend registry.local:5000/${DRONE_COMMIT_BRANCH}:${DRONE_COMMIT_SHA:0:8}-linux-arm64 | |
- docker manifest push --insecure registry.local:5000/${DRONE_COMMIT_BRANCH}:${DRONE_COMMIT_SHA:0:8} | |
services: | |
- name: docker | |
image: docker:20-dind | |
privileged: true | |
entrypoint: | |
- "dockerd" | |
volumes: | |
- name: dockersock | |
path: /var/run | |
command: | |
- "--experimental" | |
- "--host=unix:///var/run/docker.sock" | |
- "--insecure-registry=registry.local:5000" | |
volumes: | |
- name: dockersock | |
temp: {} | |
depends_on: | |
- linux-amd64 | |
- linux-arm64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This pipeline is based on examples in Drone and Docker documentation. Although it doesn't use any of the official drone plugins since they're mostly outdated and sometimes even broken, also the same result can be easily achieved only with the official
docker:dind
image(it took me several hours to make this work, just putting it here in case someone else has use for it).