2
0
mirror of https://github.com/spritsail/alpine.git synced 2025-06-14 15:11:12 +00:00

1 Commits

Author SHA1 Message Date
80cdda202e Build amd64/arm64 multiarch images
Signed-off-by: Adam Dodman <adam@adam-ant.co.uk>
Signed-off-by: Joe Groocock <me@frebib.net>
2022-06-17 12:29:39 +00:00
2 changed files with 54 additions and 60 deletions

View File

@ -1,28 +1,29 @@
repo = "spritsail/alpine"
archs = ["amd64", "arm64"]
versions = ["edge", "3.14", "3.15", "3.16"]
branches = ["master"]
versions = {
"3.21": [],
"3.22": ["latest"],
"edge": [],
}
def main(ctx):
builds = []
for ver, tags in versions.items():
for ver in versions:
depends_on = []
srctpl = "drone/%s/${DRONE_BUILD_NUMBER}:%s-ARCH" % (ctx.repo.slug, ver)
for arch in archs:
key = "build-%s-%s" % (ver, arch)
builds.append(step(ver, arch, key))
tmprepo = "drone/%s/${DRONE_BUILD_NUMBER}:%s-%s" % (ctx.repo.slug, ver, arch)
builds.append(step(ver, arch, key, tmprepo))
depends_on.append(key)
if ctx.build.branch in branches:
builds.extend(publish(ver, depends_on, tags))
tags = []
if ver == versions[-1]:
tags.append("latest")
builds.append(publish(ver, srctpl, depends_on, tags))
return builds
def step(ver, arch, key):
def step(ver, arch, key, tmprepo):
vertest = "grep -q '%s' /etc/alpine-release && " % ver if ver != "edge" else ""
return {
"kind": "pipeline",
@ -31,9 +32,6 @@ def step(ver, arch, key):
"os": "linux",
"arch": arch,
},
"environment": {
"DOCKER_IMAGE_TOKEN": ver,
},
"steps": [
{
"name": "build",
@ -43,6 +41,7 @@ def step(ver, arch, key):
"build_args": [
"ALPINE_TAG=%s" % ver,
],
"repo": tmprepo,
},
},
{
@ -51,7 +50,7 @@ def step(ver, arch, key):
"pull": "always",
"settings": {
"run": vertest + "su-exec nobody apk --version",
"verbose": "true",
"repo": tmprepo,
},
},
{
@ -59,54 +58,49 @@ def step(ver, arch, key):
"image": "spritsail/docker-publish",
"pull": "always",
"settings": {
"from": tmprepo,
"repo": tmprepo,
"registry": {"from_secret": "registry_url"},
"login": {"from_secret": "registry_login"},
"username": {"from_secret": "registry_username"},
"password": {"from_secret": "registry_password"},
},
"when": {
"branch": branches,
"event": ["push", "cron"],
"event": ["push"],
},
},
]
}
def publish(ver, depends, tags=[]):
return [
{
def publish(ver, srctpl, depends, tags=[]):
return {
"kind": "pipeline",
"name": "publish-%s-%s" % (ver, name),
"name": "publish-%s" % ver,
"depends_on": depends,
"platform": {
"os": "linux",
},
"environment": {
"DOCKER_IMAGE_TOKEN": ver,
},
"steps": [
{
"name": "publish",
"image": "spritsail/docker-multiarch-publish",
"pull": "always",
"settings": {
"src_template": srctpl,
"src_registry": {"from_secret": "registry_url"},
"src_login": {"from_secret": "registry_login"},
"dest_registry": registry,
"src_username": {"from_secret": "registry_username"},
"src_password": {"from_secret": "registry_password"},
"dest_repo": repo,
"dest_login": {"from_secret": login_secret},
"dest_username": {"from_secret": "docker_username"},
"dest_password": {"from_secret": "docker_password"},
"tags": [ver] + tags,
},
"when": {
"branch": branches,
"event": ["push", "cron"],
"event": ["push"],
},
},
],
]
}
for name, registry, login_secret in [
("dockerhub", "index.docker.io", "docker_login"),
("spritsail", "registry.spritsail.io", "spritsail_login"),
("ghcr", "ghcr.io", "ghcr_login"),
]
]
# vim: ft=python sw=2

View File

@ -1,15 +1,15 @@
ARG ALPINE_TAG=3.22
ARG ALPINE_TAG=3.16
FROM alpine:$ALPINE_TAG
ARG ALPINE_TAG
LABEL org.opencontainers.image.authors="Spritsail <alpine@spritsail.io>" \
org.opencontainers.image.title="Alpine Linux" \
org.opencontainers.image.url="https://github.com/gliderlabs/docker-alpine" \
org.opencontainers.image.source="https://github.com/spritsail/alpine" \
org.opencontainers.image.description="Alpine Linux base image" \
org.opencontainers.image.version=${ALPINE_TAG}
LABEL maintainer="Spritsail <alpine@spritsail.io>" \
org.label-schema.vendor="Spritsail" \
org.label-schema.name="Alpine Linux" \
org.label-schema.url="https://github.com/gliderlabs/docker-alpine" \
org.label-schema.description="Alpine Linux base image" \
org.label-schema.version=${ALPINE_TAG}
# Override shell for sh-y debugging goodness
SHELL ["/bin/sh", "-exc"]