0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-11-22 10:10:39 +00:00

ci: test buildx multiarch builds (#172)

This commit is contained in:
Robert Kaussow 2023-01-12 21:21:43 +01:00 committed by GitHub
parent b47e4c07ed
commit a2f76571d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 123 deletions

View File

@ -1,2 +0,0 @@
*
!dist/

View File

@ -98,39 +98,37 @@ depends_on:
--- ---
kind: pipeline kind: pipeline
name: build-container-amd64 name: build-container
platform: platform:
os: linux os: linux
arch: amd64 arch: amd64
steps: steps:
- name: build
image: golang:1.19
commands:
- make build
- name: dryrun - name: dryrun
image: thegeeklab/drone-docker-buildx:20 image: thegeeklab/drone-docker-buildx:20
settings: settings:
dockerfile: docker/Dockerfile.amd64 dockerfile: Dockerfile.multiarch
dry_run: true dry_run: true
platforms:
- linux/amd64
- linux/arm64
provenance: false provenance: false
repo: thegeeklab/${DRONE_REPO_NAME} repo: thegeeklab/${DRONE_REPO_NAME}
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
depends_on:
- build
- name: publish-dockerhub - name: publish-dockerhub
image: thegeeklab/drone-docker-buildx:20 image: thegeeklab/drone-docker-buildx:20
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 dockerfile: Dockerfile.multiarch
dockerfile: docker/Dockerfile.amd64
password: password:
from_secret: docker_password from_secret: docker_password
platforms:
- linux/amd64
- linux/arm64
provenance: false provenance: false
repo: thegeeklab/${DRONE_REPO_NAME} repo: thegeeklab/${DRONE_REPO_NAME}
username: username:
@ -146,85 +144,12 @@ steps:
image: thegeeklab/drone-docker-buildx:20 image: thegeeklab/drone-docker-buildx:20
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 dockerfile: Dockerfile.multiarch
dockerfile: docker/Dockerfile.amd64
password:
from_secret: quay_password
provenance: false
registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: quay_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- test
---
kind: pipeline
name: build-container-arm64
platform:
os: linux
arch: arm64
steps:
- name: build
image: golang:1.19
commands:
- make build
- name: dryrun
image: thegeeklab/drone-docker-buildx:20
settings:
dockerfile: docker/Dockerfile.arm64
dry_run: true
provenance: false
repo: thegeeklab/${DRONE_REPO_NAME}
when:
ref:
- refs/pull/**
depends_on:
- build
- name: publish-dockerhub
image: thegeeklab/drone-docker-buildx:20
settings:
auto_tag: true
auto_tag_suffix: arm64
dockerfile: docker/Dockerfile.arm64
password:
from_secret: docker_password
provenance: false
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
- name: publish-quay
image: thegeeklab/drone-docker-buildx:20
settings:
auto_tag: true
auto_tag_suffix: arm64
dockerfile: docker/Dockerfile.arm64
password: password:
from_secret: quay_password from_secret: quay_password
platforms:
- linux/amd64
- linux/arm64
provenance: false provenance: false
registry: quay.io registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME} repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
@ -292,8 +217,7 @@ trigger:
depends_on: depends_on:
- build-binaries - build-binaries
- build-container-amd64 - build-container
- build-container-arm64
--- ---
kind: pipeline kind: pipeline
@ -304,34 +228,6 @@ platform:
arch: amd64 arch: amd64
steps: steps:
- name: manifest-dockerhub
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: docker_password
spec: docker/manifest.tmpl
username:
from_secret: docker_username
when:
status:
- success
- name: manifest-quay
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: quay_password
spec: docker/manifest-quay.tmpl
username:
from_secret: quay_username
when:
status:
- success
- name: pushrm-dockerhub - name: pushrm-dockerhub
image: chko/docker-pushrm:1 image: chko/docker-pushrm:1
environment: environment:
@ -387,6 +283,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: 0263cf6df573ba55933b837db50a6f7e3a8fd422bb4506bc09a97e89085473bd hmac: 0a2edb569e156dbb6c32a44b812757a28156b31a44325585c0f19ee0c6706fd4
... ...

View File

@ -1,3 +1,13 @@
FROM --platform=$BUILDPLATFORM golang:1.19 as build
ARG TARGETOS
ARG TARGETARCH
ADD . /src
WORKDIR /src
RUN make build
FROM docker:20.10-dind@sha256:2e0135466bcb3398e7f3943b87aef5c036dbaf1683805b8bfe992a477f7269e9 FROM docker:20.10-dind@sha256:2e0135466bcb3398e7f3943b87aef5c036dbaf1683805b8bfe992a477f7269e9
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>" LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
@ -23,6 +33,6 @@ RUN apk --update add --virtual .build-deps curl && \
rm -rf /var/cache/apk/* && \ rm -rf /var/cache/apk/* && \
rm -rf /tmp/* rm -rf /tmp/*
ADD dist/drone-docker-buildx /bin/ COPY --from=build /src/dist/drone-docker-buildx /bin/drone-docker-buildx
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"] ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"]

View File

@ -22,6 +22,8 @@ GENERATE ?=
XGO_VERSION := go-1.19.x XGO_VERSION := go-1.19.x
XGO_TARGETS ?= linux/amd64,linux/arm64 XGO_TARGETS ?= linux/amd64,linux/arm64
TARGETOS ?= linux
TARGETARCH ?= amd64
TAGS ?= netgo TAGS ?= netgo
ifndef VERSION ifndef VERSION
@ -69,7 +71,7 @@ test:
build: $(DIST)/$(EXECUTABLE) build: $(DIST)/$(EXECUTABLE)
$(DIST)/$(EXECUTABLE): $(SOURCES) $(DIST)/$(EXECUTABLE): $(SOURCES)
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE) GOOS=${TARGETOS} GOARCH=${TARGETARCH} $(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
$(DIST_DIRS): $(DIST_DIRS):
mkdir -p $(DIST_DIRS) mkdir -p $(DIST_DIRS)