updates to use new multi-arch template

This commit is contained in:
James Brumond 2022-12-03 19:20:52 -08:00
parent e6e4fac6c7
commit bec51c0a22
Signed by: james
GPG Key ID: 24BA25B8B303B023
5 changed files with 117 additions and 88 deletions

View File

@ -1,21 +0,0 @@
---
kind: pipeline
type: kubernetes
name: build-{{ .input.os }}-{{ .input.arch }}
trigger:
event: [ push ]
branch: [ master ]
steps:
- name: build
image: plugins/docker
settings:
registry: https://gitea.internal.example.com
username: drone
password:
from_secret: gitea-internal-password
repo: gitea.internal.example.com/{{ .input.repo }}-{{ .input.os }}-{{ .input.arch }}
cache_from: gitea.internal.example.com/{{ .input.repo }}-{{ .input.os }}-{{ .input.arch }}:ci
tags:
- "ci"

109
multiarch-container.yaml Normal file
View File

@ -0,0 +1,109 @@
{{- range $i, $plat := .input.platforms -}}
---
kind: pipeline
type: kubernetes
name: build-{{ $plat.os }}-{{ $plat.arch }}
trigger:
event: [ push ]
branch: [ master ]
steps:
- name: build
image: plugins/docker
settings:
registry: https://gitea.internal.example.com
username: drone
password:
from_secret: gitea-internal-password
repo: gitea.internal.example.com/{{ $.input.repo }}
cache_from: gitea.internal.example.com/{{ $.input.repo }}:ci-{{ $plat.os }}-{{ $plat.arch }}
build_args:
- OS={{ $plat.os }}
- ARCH={{ $plat.arch }}
{{ range $.input.build_args }}
- {{ . }}
{{ end }}
tags:
- ci-{{ $plat.os }}-{{ $plat.arch }}
---
kind: pipeline
type: kubernetes
name: publish-{{ $plat.os }}-{{ $plat.arch }}
trigger:
event: [ promote ]
target: [ publish, "publish-{{ $plat.os }}-{{ $plat.arch }}" ]
steps:
- name: build-and-publish
image: plugins/docker
settings:
registry: https://gitea.internal.example.com
username: drone
password:
from_secret: gitea-internal-password
repo: gitea.internal.example.com/{{ $.input.repo }}
cache_from: gitea.internal.example.com/{{ $.input.repo }}:ci-{{ $plat.os }}-{{ $plat.arch }}
build_args:
- OS={{ $plat.os }}
- ARCH={{ $plat.arch }}
{{ range $.input.build_args }}
- {{ . }}
{{ end }}
tags:
- latest-{{ $plat.os }}-{{ $plat.arch }}
{{ range $.input.tags }}
- {{ . }}-{{ $plat.os }}-{{ $plat.arch }}
{{ end }}
{{ end }}
---
kind: pipeline
type: kubernetes
name: publish-multiarch-manifest
trigger:
event: [ promote ]
target: [ publish ]
steps:
- name: deploy
image: gitea.internal.example.com/images/docker:{{ if .input.docker_image_tag }}{{ .input.docker_image_tag }}{{ else }}latest{{ end }}
volumes:
- name: dockersock
path: /var/run/
environment:
DOCKER_REGISTRY: https://gitea.internal.example.com
DOCKER_USER: drone
DOCKER_PASS:
from_secret: gitea-internal-password
commands:
- /bin/docker-setup
- |
docker manifest create \
gitea.internal.example.com/{{ .input.repo }}:latest \
{{ range .input.platforms -}}
--amend gitea.internal.example.com/{{ $.input.repo }}:latest-{{ .os }}-{{ .arch }} \
{{- end }}
- docker manifest push gitea.internal.example.com/{{ .input.repo }}:latest
{{ range $i, $tag := $.input.tags }}
- |
docker manifest create \
gitea.internal.example.com/{{ $.input.repo }}:{{ $tag }} \
{{ range $.input.platforms -}}
gitea.internal.example.com/{{ $.input.repo }}:{{ $tag }}-{{ .os }}-{{ .arch }} \
{{- end }}
- docker manifest push gitea.internal.example.com/{{ $.input.repo }}:{{ $tag }}
{{ end }}
volumes:
- name: dockersock
host:
path: /var/run/
depends_on:
{{ range .input.platforms }}
- publish-{{ .os }}-{{ .arch }}
{{ end }}

View File

@ -1,28 +0,0 @@
---
kind: pipeline
type: kubernetes
name: publish-multiarch-manifest
trigger:
event: [ promote ]
target: [ publish ]
steps:
- name: publish-manifest
image: plugins/manifest
settings:
registry: https://gitea.internal.example.com
username: drone
password:
from_secret: gitea-internal-password
target: gitea.internal.example.com/{{ .input.repo }}
template: gitea.internal.example.com/{{ .input.repo }}-OS-ARCH
platforms:
{{ range .input.platforms }}
- {{ .os }}/{{ .arch }}
{{ end }}
depends_on:
{{ range .input.platforms }}
- publish-{{ .os }}-{{ .arch }}
{{ range .input.platforms }}

View File

@ -1,21 +0,0 @@
---
kind: pipeline
type: kubernetes
name: publish-{{ .input.os }}-{{ .input.arch }}
trigger:
event: [ promote ]
target: [ "publish-{{ .input.os }}-{{ .input.arch }}" ]
steps:
- name: build-and-publish
image: plugins/docker
settings:
registry: https://gitea.internal.example.com
username: drone
password:
from_secret: gitea-internal-password
repo: gitea.internal.example.com/{{ .input.repo }}-{{ .input.os }}-{{ .input.arch }}
cache_from: gitea.internal.example.com/{{ .input.repo }}-{{ .input.os }}-{{ .input.arch }}:ci
tags:
- "latest"

View File

@ -10,26 +10,16 @@ See https://blog.jbrumond.me/post/raspberry-pi-cluster-part-4:-gitea-and-drone f
```yaml ```yaml
--- ---
kind: template kind: template
load: build.yaml load: multiarch-container.yaml
data: data:
repo: examples/docker repo: images/example-image-name
os: linux tags:
arch: arm64 - "1.2.3"
- "1.2"
--- - "1"
kind: template
load: publish.yaml
data:
repo: examples/docker
os: linux
arch: arm64
---
kind: template
load: multiarch.yaml
data:
repo: examples/docker
platforms: platforms:
- os: linux - os: linux
arch: arm64 arch: arm64
- os: linux
arch: amd64
``` ```