Skip to content
Snippets Groups Projects
Commit 59171554 authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

:sparkles:docker_build: tag if present, and push

parent 1eb9dd7e
No related branches found
No related tags found
1 merge request!68🔖 14.0.0
......@@ -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
------
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment