diff --git a/ci/release-image/Dockerfile b/ci/release-image/Dockerfile index cbc97c3ad..82c80c58b 100644 --- a/ci/release-image/Dockerfile +++ b/ci/release-image/Dockerfile @@ -1,9 +1,10 @@ # syntax=docker/dockerfile:experimental +ARG BASE=debian:11 FROM scratch AS packages COPY release-packages/code-server*.deb /tmp/ -FROM debian:11 +FROM $BASE RUN apt-get update \ && apt-get install -y \ diff --git a/ci/release-image/docker-bake.hcl b/ci/release-image/docker-bake.hcl index 27bf2194f..4526c8a1e 100644 --- a/ci/release-image/docker-bake.hcl +++ b/ci/release-image/docker-bake.hcl @@ -6,17 +6,63 @@ variable "VERSION" { default = "latest" } -group "default" { - targets = ["code-server"] +variable "DOCKER_REGISTRY" { + default = "docker.io/codercom/code-server" } -target "code-server" { - dockerfile = "ci/release-image/Dockerfile" - tags = [ - "docker.io/codercom/code-server:latest", - notequal("latest",VERSION) ? "docker.io/codercom/code-server:${VERSION}" : "", - "ghcr.io/coder/code-server:latest", - notequal("latest",VERSION) ? "ghcr.io/coder/code-server:${VERSION}" : "", +variable "GITHUB_REGISTRY" { + default = "ghcr.io/coder/code-server" +} + +group "default" { + targets = [ + "code-server-debian-11", + "code-server-ubuntu-focal", ] +} + +function "prepend_hyphen_if_not_null" { + params = [tag] + result = notequal("","${tag}") ? "-${tag}" : "${tag}" +} + +# use empty tag (tag="") to generate default tags +function "gen_tags" { + params = [registry, tag] + result = notequal("","${registry}") ? [ + notequal("", "${tag}") ? "${registry}:${tag}" : "${registry}:latest", + notequal("latest",VERSION) ? "${registry}:${VERSION}${prepend_hyphen_if_not_null(tag)}" : "", + ] : [] +} + +# helper function to generate tags for docker registry and github registry. +# set (DOCKER|GITHUB)_REGISTRY="" to disable corresponding registry +function "gen_tags_for_docker_and_ghcr" { + params = [tag] + result = concat( + gen_tags("${DOCKER_REGISTRY}", "${tag}"), + gen_tags("${GITHUB_REGISTRY}", "${tag}"), + ) +} + +target "code-server-debian-11" { + dockerfile = "ci/release-image/Dockerfile" + tags = concat( + gen_tags_for_docker_and_ghcr(""), + gen_tags_for_docker_and_ghcr("debian"), + gen_tags_for_docker_and_ghcr("bullseye"), + ) + platforms = ["linux/amd64", "linux/arm64"] +} + +target "code-server-ubuntu-focal" { + dockerfile = "ci/release-image/Dockerfile" + tags = concat( + gen_tags_for_docker_and_ghcr("ubuntu"), + gen_tags_for_docker_and_ghcr("focal"), + ) + args = { + BASE = "ubuntu:focal" + } platforms = ["linux/amd64", "linux/arm64"] }