diff --git a/NEWS.rst b/NEWS.rst index 1eb9dd7ea37d3297a950b3d8db177397d2e09e3e_TkVXUy5yc3Q=..591715545a0cd8c8e768e2c9a9be7bfff433f4a0_TkVXUy5yc3Q= 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -7,6 +7,10 @@ Allow not setting the database owner in do_tests. +Remove static image support. + +``docker_build`` also tag with any current tag if any. + 13.3.0 ------ diff --git a/odoo_scripts/docker_build.py b/odoo_scripts/docker_build.py index 1eb9dd7ea37d3297a950b3d8db177397d2e09e3e_b2Rvb19zY3JpcHRzL2RvY2tlcl9idWlsZC5weQ==..591715545a0cd8c8e768e2c9a9be7bfff433f4a0_b2Rvb19zY3JpcHRzL2RvY2tlcl9idWlsZC5weQ== 100644 --- a/odoo_scripts/docker_build.py +++ b/odoo_scripts/docker_build.py @@ -18,5 +18,5 @@ _logger = logging.getLogger(__name__) -__version__ = "1.0.0" +__version__ = "1.1.0" __date__ = "2018-04-04" @@ -22,5 +22,5 @@ __date__ = "2018-04-04" -__updated__ = "2020-09-11" +__updated__ = "2021-12-13" def __parser(): @@ -34,7 +34,7 @@ program_license = """%s Created by Vincent Hatakeyama on %s. - Copyright 2018, 2019, 2020 XCG Consulting. All rights reserved. + Copyright 2018, 2019, 2020, 2021 XCG Consulting. All rights reserved. Licensed under the MIT License @@ -101,8 +101,8 @@ registry = c.registry project = c.image odoo_type = c.odoo_type - image = "%s/%s:latest" % (registry, project) - _logger.debug("Docker image: %s", image) + repository = f"{registry}/{project}" + _logger.debug("Docker repository: %s", repository) # TODO ensureconf if ensureconf: raise NotImplementedError @@ -118,6 +118,9 @@ signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) + # used to retag + tags = [] + buildargs = dict() if os.path.exists(".hg"): tags = check_output(["hg", "identify", "--tags"]).decode() @@ -121,4 +124,6 @@ buildargs = dict() if os.path.exists(".hg"): tags = check_output(["hg", "identify", "--tags"]).decode() + buildargs["VERSION"] = tags + buildargs["SENTRY_RELEASE"] = tags if tags: @@ -124,5 +129,5 @@ if tags: - buildargs["VERSION"] = tags + tags = tags.split() buildargs["VCS_URL"] = check_output( ["hg", "paths", "default"] ).decode() @@ -181,7 +186,7 @@ rm=True, pull=pull, buildargs=buildargs, - tag=image, + tag=repository, dockerfile=dockerfile, ) for line in builder: @@ -194,4 +199,8 @@ return 1 if dev: call(["rm", dockerfile]) + # retag + for tag in tags: + _logger.info("Docker with tag %s", tag) + docker_client.images.get(repository).tag(repository, tag=tag) @@ -197,4 +206,2 @@ - # TODO docker tag with tags/bookmarks (unused so maybe no need) - # TODO docker push (only when asked for) if push: @@ -200,5 +207,15 @@ if push: - raise NotImplementedError + _logger.info("Docker push %s", repository) + for line in docker_client.images.push( + repository, stream=True, decode=True + ): + _logger.debug(line) + for tag in tags: + _logger.info("Docker push %s:%s", repository, tag) + for line in docker_client.images.push( + repository, tag=tag, stream=True, decode=True + ): + _logger.debug(line) # XXX call cleanup more intelligently signal_handler(0, None) return 0