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" repo = "spritsail/alpine"
archs = ["amd64", "arm64"] archs = ["amd64", "arm64"]
versions = ["edge", "3.14", "3.15", "3.16"]
branches = ["master"] branches = ["master"]
versions = {
"3.21": [],
"3.22": ["latest"],
"edge": [],
}
def main(ctx): def main(ctx):
builds = [] builds = []
for ver, tags in versions.items(): for ver in versions:
depends_on = [] depends_on = []
srctpl = "drone/%s/${DRONE_BUILD_NUMBER}:%s-ARCH" % (ctx.repo.slug, ver)
for arch in archs: for arch in archs:
key = "build-%s-%s" % (ver, arch) 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) depends_on.append(key)
if ctx.build.branch in branches: 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 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 "" vertest = "grep -q '%s' /etc/alpine-release && " % ver if ver != "edge" else ""
return { return {
"kind": "pipeline", "kind": "pipeline",
@ -31,9 +32,6 @@ def step(ver, arch, key):
"os": "linux", "os": "linux",
"arch": arch, "arch": arch,
}, },
"environment": {
"DOCKER_IMAGE_TOKEN": ver,
},
"steps": [ "steps": [
{ {
"name": "build", "name": "build",
@ -42,16 +40,17 @@ def step(ver, arch, key):
"settings": { "settings": {
"build_args": [ "build_args": [
"ALPINE_TAG=%s" % ver, "ALPINE_TAG=%s" % ver,
], ],
}, "repo": tmprepo,
}, },
},
{ {
"name": "test", "name": "test",
"image": "spritsail/docker-test", "image": "spritsail/docker-test",
"pull": "always", "pull": "always",
"settings": { "settings": {
"run": vertest + "su-exec nobody apk --version", "run": vertest + "su-exec nobody apk --version",
"verbose": "true", "repo": tmprepo,
}, },
}, },
{ {
@ -59,54 +58,49 @@ def step(ver, arch, key):
"image": "spritsail/docker-publish", "image": "spritsail/docker-publish",
"pull": "always", "pull": "always",
"settings": { "settings": {
"from": tmprepo,
"repo": tmprepo,
"registry": {"from_secret": "registry_url"}, "registry": {"from_secret": "registry_url"},
"login": {"from_secret": "registry_login"}, "username": {"from_secret": "registry_username"},
"password": {"from_secret": "registry_password"},
}, },
"when": { "when": {
"branch": branches, "branch": branches,
"event": ["push", "cron"], "event": ["push"],
}, },
}, },
] ]
} }
def publish(ver, depends, tags=[]): def publish(ver, srctpl, depends, tags=[]):
return [ return {
{ "kind": "pipeline",
"kind": "pipeline", "name": "publish-%s" % ver,
"name": "publish-%s-%s" % (ver, name), "depends_on": depends,
"depends_on": depends, "platform": {
"platform": { "os": "linux",
"os": "linux", },
}, "steps": [
"environment": { {
"DOCKER_IMAGE_TOKEN": ver, "name": "publish",
}, "image": "spritsail/docker-multiarch-publish",
"steps": [ "pull": "always",
{ "settings": {
"name": "publish", "src_template": srctpl,
"image": "spritsail/docker-multiarch-publish", "src_registry": {"from_secret": "registry_url"},
"pull": "always", "src_username": {"from_secret": "registry_username"},
"settings": { "src_password": {"from_secret": "registry_password"},
"src_registry": {"from_secret": "registry_url"}, "dest_repo": repo,
"src_login": {"from_secret": "registry_login"}, "dest_username": {"from_secret": "docker_username"},
"dest_registry": registry, "dest_password": {"from_secret": "docker_password"},
"dest_repo": repo, "tags": [ver] + tags,
"dest_login": {"from_secret": login_secret},
"tags": [ver] + tags,
},
"when": {
"branch": branches,
"event": ["push", "cron"],
},
}, },
], "when": {
} "branch": branches,
for name, registry, login_secret in [ "event": ["push"],
("dockerhub", "index.docker.io", "docker_login"), },
("spritsail", "registry.spritsail.io", "spritsail_login"), },
("ghcr", "ghcr.io", "ghcr_login"),
] ]
] }
# vim: ft=python sw=2 # 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 FROM alpine:$ALPINE_TAG
ARG ALPINE_TAG ARG ALPINE_TAG
LABEL org.opencontainers.image.authors="Spritsail <alpine@spritsail.io>" \ LABEL maintainer="Spritsail <alpine@spritsail.io>" \
org.opencontainers.image.title="Alpine Linux" \ org.label-schema.vendor="Spritsail" \
org.opencontainers.image.url="https://github.com/gliderlabs/docker-alpine" \ org.label-schema.name="Alpine Linux" \
org.opencontainers.image.source="https://github.com/spritsail/alpine" \ org.label-schema.url="https://github.com/gliderlabs/docker-alpine" \
org.opencontainers.image.description="Alpine Linux base image" \ org.label-schema.description="Alpine Linux base image" \
org.opencontainers.image.version=${ALPINE_TAG} org.label-schema.version=${ALPINE_TAG}
# Override shell for sh-y debugging goodness # Override shell for sh-y debugging goodness
SHELL ["/bin/sh", "-exc"] SHELL ["/bin/sh", "-exc"]