Commit ae9ebed2 authored by Carine Dengler's avatar Carine Dengler
Browse files

fix: add aliases

parent 0aabc2d9cdaa
......@@ -22,14 +22,27 @@ class CubicWebImage:
def cubicweb_major_version(self):
return self.cubicweb_version.rsplit('.', 1)[0]
def __lte__(self, other):
lversion = self.cubicweb_version.split(".")
rversion = other.cubicweb_version.split(".")
return lversion <= rversion
def tag(self):
if self.package_version == 'dev':
return 'dev'
return f"{REGISTRY}:{self.base_docker_image}-{self.cubicweb_version}"
def base_docker_image(self):
return f"{self.python}-{self.debian}"
def major_tag(self):
if self.package_version == 'dev':
return 'dev'
return f"{REGISTRY}:{self.base_docker_image}-{self.cubicweb_major_version}"
LOG = logging.getLogger(__name__)
REGISTRY = 'logilab/cubicweb'
......@@ -76,18 +89,30 @@ def _cwdev(_cache={}):
return _cache[None]
def tag_aliases():
for alias, source in ALIASES:
if alias == 'buildpackage':
check_call('docker', 'tag', _tag(source), _tag(alias))
def tag_aliases(images: list[CubicWebImage]):
latest = {}
for cwimage in [img for img in images if img.package_version != 'dev']:
version = cwimage.cubicweb_major_version
if version not in latest:
latest[version] = cwimage
if latest[version] <= cwimage:
latest[version] = cwimage
last_major = max(latest.values())
for major, img in (*latest.items(), ('latest', last_major)):
tag = f"{REGISTRY}:{major}"
for onbuild in [None, 'onbuild']:
if alias == 'latest' and onbuild == 'onbuild':
tag = _tag('onbuild')
if onbuild == 'onbuild':
tag = f"{REGISTRY}:{major}-{onbuild}"
tag = _tag(alias, onbuild)
src = _tag(source, onbuild)
tag = f"{REGISTRY}:{major}"
src = img.tag
check_call('docker', 'tag', src, tag)
check_call('docker', 'tag', src, img.major_tag)
if major == 'buildpackage':
check_call('docker', 'tag', img.tag, f"{REGISTRY}:{major}")
def build_image(image: CubicWebImage, onbuild: Optional[str], no_cache=False, registry=None):
......@@ -234,8 +259,11 @@ if __name__ == '__main__':
images = get_cubicweb_images(["stretch", "buster"], ["py27"])
images += get_cubicweb_images(["stretch"], ["py35"])
images += get_cubicweb_images(["buster"], ["py37"])
CubicWebImage("py37", "buster", "python3-cubicweb", "dev")
if args.push:
build(images=images, rebuild=args.checkrebuild)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment