chore(docker): use buildx to build multiarch images
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2021-01-10 23:06:23 +01:00
parent 1e0fae2bc9
commit 2e1c7299c4
2 changed files with 73 additions and 208 deletions

View File

@ -27,35 +27,6 @@ local PipelineBuildContainer(arch='amd64') = {
arch: 'amd64', arch: 'amd64',
}, },
steps: [ steps: [
{
name: 'wait-for',
image: 'thegeeklab/wait-for',
commands: [
'wait-for dind-' + arch + ':2376',
],
environment: {
WAITFOR_TIMEOUT: 60,
},
},
{
name: 'dryrun',
image: 'thegeeklab/drone-docker-buildx',
settings: {
config: { from_secret: 'docker_config' },
dry_run: true,
dockerfile: 'docker/Dockerfile.' + std.split(arch, '_')[0],
platforms: [
'linux/' + std.strReplace(arch, '_', '/'),
],
repo: 'thegeeklab/buildx-alpine',
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
},
depends_on: ['wait-for'],
when: {
ref: ['refs/pull/**'],
},
},
{ {
name: 'tags', name: 'tags',
image: 'thegeeklab/docker-autotag', image: 'thegeeklab/docker-autotag',
@ -64,50 +35,43 @@ local PipelineBuildContainer(arch='amd64') = {
DOCKER_AUTOTAG_IGNORE_PRERELEASE: 'True', DOCKER_AUTOTAG_IGNORE_PRERELEASE: 'True',
DOCKER_AUTOTAG_OUTPUT_FILE: '.tags', DOCKER_AUTOTAG_OUTPUT_FILE: '.tags',
DOCKER_AUTOTAG_VERSION: '${DRONE_TAG}', DOCKER_AUTOTAG_VERSION: '${DRONE_TAG}',
DOCKER_AUTOTAG_SUFFIX: std.split(arch, '_')[0],
}, },
depends_on: ['wait-for'], },
{
name: 'dryrun',
image: 'thegeeklab/drone-docker-buildx',
privileged: true,
settings: {
dry_run: true,
dockerfile: 'Dockerfile.' + std.split(arch, '_')[0],
platforms: [
'linux/' + std.strReplace(arch, '_', '/'),
],
repo: 'thegeeklab/buildx-alpine',
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
},
depends_on: ['tags'],
when: { when: {
ref: ['refs/heads/main', 'refs/tags/**'], ref: ['refs/pull/**'],
}, },
}, },
{ {
name: 'publish-dockerhub', name: 'publish-dockerhub',
image: 'jdrouet/docker-with-buildx:stable', image: 'thegeeklab/drone-docker-buildx',
commands: [ settings: {
'docker login -u "$$DOCKER_USERNAME" -p "$$DOCKER_PASSWORD"', dockerfile: 'Dockerfile.' + std.split(arch, '_')[0],
'docker buildx create --use', repo: 'thegeeklab/buildx-alpine',
'docker buildx build --push --platform linux/' + std.strReplace(arch, '_', '/') + ' --tag thegeeklab/buildx-alpine:' + std.split(arch, '_')[0] + ' -f "$$DOCKERFILE" .', username: { from_secret: 'docker_username' },
], password: { from_secret: 'docker_password' },
environment: {
DOCKER_PASSWORD: { from_secret: 'docker_password' },
DOCKER_USERNAME: { from_secret: 'docker_username' },
DOCKERFILE: 'Dockerfile.' + std.split(arch, '_')[0],
}, },
volumes: [{
name: 'dockersock-' + arch,
path: '/var/run',
}],
when: { when: {
ref: ['refs/heads/main', 'refs/tags/**'], ref: ['refs/heads/main', 'refs/tags/**'],
}, },
depends_on: ['tags'], depends_on: ['tags'],
}, },
], ],
services: [
{
name: 'dind-' + arch,
image: 'docker:dind',
privileged: true,
volumes: [{
name: 'dockersock-' + arch,
path: '/var/run',
}],
},
],
volumes: [{
name: 'dockersock-' + arch,
temp: {},
}],
depends_on: [ depends_on: [
'test', 'test',
], ],
@ -118,7 +82,6 @@ local PipelineBuildContainer(arch='amd64') = {
local PipelineNotifications = { local PipelineNotifications = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'notifications', name: 'notifications',
platform: { platform: {
os: 'linux', os: 'linux',
@ -130,7 +93,6 @@ local PipelineNotifications = {
name: 'manifest-dockerhub', name: 'manifest-dockerhub',
settings: { settings: {
ignore_missing: true, ignore_missing: true,
auto_tag: true,
username: { from_secret: 'docker_username' }, username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' }, password: { from_secret: 'docker_password' },
spec: 'manifest.tmpl', spec: 'manifest.tmpl',

View File

@ -27,19 +27,19 @@ platform:
arch: amd64 arch: amd64
steps: steps:
- name: wait-for - name: tags
image: thegeeklab/wait-for image: thegeeklab/docker-autotag
commands:
- wait-for dind-amd64:2376
environment: environment:
WAITFOR_TIMEOUT: 60 DOCKER_AUTOTAG_FORCE_LATEST: True
DOCKER_AUTOTAG_IGNORE_PRERELEASE: True
DOCKER_AUTOTAG_OUTPUT_FILE: .tags
DOCKER_AUTOTAG_SUFFIX: amd64
DOCKER_AUTOTAG_VERSION: ${DRONE_TAG}
- name: dryrun - name: dryrun
image: thegeeklab/drone-docker-buildx image: thegeeklab/drone-docker-buildx
settings: settings:
config: dockerfile: Dockerfile.amd64
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64
dry_run: true dry_run: true
password: password:
from_secret: docker_password from_secret: docker_password
@ -48,41 +48,22 @@ steps:
repo: thegeeklab/buildx-alpine repo: thegeeklab/buildx-alpine
username: username:
from_secret: docker_username from_secret: docker_username
privileged: true
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
depends_on: depends_on:
- wait-for - tags
- name: tags
image: thegeeklab/docker-autotag
environment:
DOCKER_AUTOTAG_FORCE_LATEST: True
DOCKER_AUTOTAG_IGNORE_PRERELEASE: True
DOCKER_AUTOTAG_OUTPUT_FILE: .tags
DOCKER_AUTOTAG_VERSION: ${DRONE_TAG}
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- wait-for
- name: publish-dockerhub - name: publish-dockerhub
image: jdrouet/docker-with-buildx:stable image: thegeeklab/drone-docker-buildx
commands: settings:
- docker login -u "$$DOCKER_USERNAME" -p "$$DOCKER_PASSWORD" dockerfile: Dockerfile.amd64
- docker buildx create --use password:
- docker buildx build --push --platform linux/amd64 --tag thegeeklab/buildx-alpine:amd64 -f "$$DOCKERFILE" .
environment:
DOCKERFILE: Dockerfile.amd64
DOCKER_PASSWORD:
from_secret: docker_password from_secret: docker_password
DOCKER_USERNAME: repo: thegeeklab/buildx-alpine
username:
from_secret: docker_username from_secret: docker_username
volumes:
- name: dockersock-amd64
path: /var/run
when: when:
ref: ref:
- refs/heads/main - refs/heads/main
@ -90,18 +71,6 @@ steps:
depends_on: depends_on:
- tags - tags
services:
- name: dind-amd64
image: docker:dind
privileged: true
volumes:
- name: dockersock-amd64
path: /var/run
volumes:
- name: dockersock-amd64
temp: {}
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -120,19 +89,19 @@ platform:
arch: amd64 arch: amd64
steps: steps:
- name: wait-for - name: tags
image: thegeeklab/wait-for image: thegeeklab/docker-autotag
commands:
- wait-for dind-arm64_v8:2376
environment: environment:
WAITFOR_TIMEOUT: 60 DOCKER_AUTOTAG_FORCE_LATEST: True
DOCKER_AUTOTAG_IGNORE_PRERELEASE: True
DOCKER_AUTOTAG_OUTPUT_FILE: .tags
DOCKER_AUTOTAG_SUFFIX: arm64
DOCKER_AUTOTAG_VERSION: ${DRONE_TAG}
- name: dryrun - name: dryrun
image: thegeeklab/drone-docker-buildx image: thegeeklab/drone-docker-buildx
settings: settings:
config: dockerfile: Dockerfile.arm64
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64
dry_run: true dry_run: true
password: password:
from_secret: docker_password from_secret: docker_password
@ -141,41 +110,22 @@ steps:
repo: thegeeklab/buildx-alpine repo: thegeeklab/buildx-alpine
username: username:
from_secret: docker_username from_secret: docker_username
privileged: true
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
depends_on: depends_on:
- wait-for - tags
- name: tags
image: thegeeklab/docker-autotag
environment:
DOCKER_AUTOTAG_FORCE_LATEST: True
DOCKER_AUTOTAG_IGNORE_PRERELEASE: True
DOCKER_AUTOTAG_OUTPUT_FILE: .tags
DOCKER_AUTOTAG_VERSION: ${DRONE_TAG}
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- wait-for
- name: publish-dockerhub - name: publish-dockerhub
image: jdrouet/docker-with-buildx:stable image: thegeeklab/drone-docker-buildx
commands: settings:
- docker login -u "$$DOCKER_USERNAME" -p "$$DOCKER_PASSWORD" dockerfile: Dockerfile.arm64
- docker buildx create --use password:
- docker buildx build --push --platform linux/arm64/v8 --tag thegeeklab/buildx-alpine:arm64 -f "$$DOCKERFILE" .
environment:
DOCKERFILE: Dockerfile.arm64
DOCKER_PASSWORD:
from_secret: docker_password from_secret: docker_password
DOCKER_USERNAME: repo: thegeeklab/buildx-alpine
username:
from_secret: docker_username from_secret: docker_username
volumes:
- name: dockersock-arm64_v8
path: /var/run
when: when:
ref: ref:
- refs/heads/main - refs/heads/main
@ -183,18 +133,6 @@ steps:
depends_on: depends_on:
- tags - tags
services:
- name: dind-arm64_v8
image: docker:dind
privileged: true
volumes:
- name: dockersock-arm64_v8
path: /var/run
volumes:
- name: dockersock-arm64_v8
temp: {}
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -213,19 +151,19 @@ platform:
arch: amd64 arch: amd64
steps: steps:
- name: wait-for - name: tags
image: thegeeklab/wait-for image: thegeeklab/docker-autotag
commands:
- wait-for dind-arm_v7:2376
environment: environment:
WAITFOR_TIMEOUT: 60 DOCKER_AUTOTAG_FORCE_LATEST: True
DOCKER_AUTOTAG_IGNORE_PRERELEASE: True
DOCKER_AUTOTAG_OUTPUT_FILE: .tags
DOCKER_AUTOTAG_SUFFIX: arm
DOCKER_AUTOTAG_VERSION: ${DRONE_TAG}
- name: dryrun - name: dryrun
image: thegeeklab/drone-docker-buildx image: thegeeklab/drone-docker-buildx
settings: settings:
config: dockerfile: Dockerfile.arm
from_secret: docker_config
dockerfile: docker/Dockerfile.arm
dry_run: true dry_run: true
password: password:
from_secret: docker_password from_secret: docker_password
@ -234,41 +172,22 @@ steps:
repo: thegeeklab/buildx-alpine repo: thegeeklab/buildx-alpine
username: username:
from_secret: docker_username from_secret: docker_username
privileged: true
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
depends_on: depends_on:
- wait-for - tags
- name: tags
image: thegeeklab/docker-autotag
environment:
DOCKER_AUTOTAG_FORCE_LATEST: True
DOCKER_AUTOTAG_IGNORE_PRERELEASE: True
DOCKER_AUTOTAG_OUTPUT_FILE: .tags
DOCKER_AUTOTAG_VERSION: ${DRONE_TAG}
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- wait-for
- name: publish-dockerhub - name: publish-dockerhub
image: jdrouet/docker-with-buildx:stable image: thegeeklab/drone-docker-buildx
commands: settings:
- docker login -u "$$DOCKER_USERNAME" -p "$$DOCKER_PASSWORD" dockerfile: Dockerfile.arm
- docker buildx create --use password:
- docker buildx build --push --platform linux/arm/v7 --tag thegeeklab/buildx-alpine:arm -f "$$DOCKERFILE" .
environment:
DOCKERFILE: Dockerfile.arm
DOCKER_PASSWORD:
from_secret: docker_password from_secret: docker_password
DOCKER_USERNAME: repo: thegeeklab/buildx-alpine
username:
from_secret: docker_username from_secret: docker_username
volumes:
- name: dockersock-arm_v7
path: /var/run
when: when:
ref: ref:
- refs/heads/main - refs/heads/main
@ -276,18 +195,6 @@ steps:
depends_on: depends_on:
- tags - tags
services:
- name: dind-arm_v7
image: docker:dind
privileged: true
volumes:
- name: dockersock-arm_v7
path: /var/run
volumes:
- name: dockersock-arm_v7
temp: {}
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -309,7 +216,6 @@ steps:
- name: manifest-dockerhub - name: manifest-dockerhub
image: plugins/manifest image: plugins/manifest
settings: settings:
auto_tag: true
ignore_missing: true ignore_missing: true
password: password:
from_secret: docker_password from_secret: docker_password
@ -352,9 +258,6 @@ steps:
- success - success
- failure - failure
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -370,6 +273,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: 0d15eda6b01d23551b72f8e12348bb1028d19c0b30cf28be2f38e737a3f9a51d hmac: c11c306a6ff27ebe6ffe119cda6ec0afd5b8426ccb72c3a71cd6209782634451
... ...