Skip to content

Commit

Permalink
[docker] Add option to force the latest tag
Browse files Browse the repository at this point in the history
This patch adds a `--force-latest` that allows users to force
using the simple `latest` tag even when the default base OS
is not used. This is useful because the latest tag is often
used to retrieve the last relevant build and is commonly used
when a user just wants to test or use their latest build.

For example if a user wants to test the quickstart with CentOS 7
they can build with `--force-latest` and run normally as opposed
to manually editing the quickstart.yml file.

This is also useful for CI/CD pipelines that always want to publish
the last build image as `latest`.

Change-Id: I13ff38683d3f923577f8728fdf30a4b3e09bc943
Reviewed-on: http://gerrit.cloudera.org:8080/17574
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <[email protected]>
  • Loading branch information
granthenke committed Jun 14, 2021
1 parent f964714 commit 56c0132
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docker/docker-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ def parse_args():
'images to docker so they can be used locally. "push" will push the '
'images to the registry.')

parser.add_argument('--force-latest', action='store_true',
help='If passed, forces adding the simple `latest` tag even though the base '
'image is not the default OS')
parser.add_argument('--skip-latest', action='store_true',
help='If passed, skips adding a tag using `-latest` along with the '
'versioned tag')
'versioned tag. Note: This overrides the --force-latest tag above.')
parser.add_argument('--tag-hash', action='store_true',
help='If passed, keeps the tags using the short git hash as the version '
'for non-release builds. Leaving this as false ensures the tags '
Expand Down Expand Up @@ -281,7 +284,7 @@ def build_tags(opts, runtime_base, dev_base, version, vcs_ref, target):
latest_tag = get_full_tag(opts.repository, target, 'latest', os_tag)
tags.append(latest_tag)
# Add the default OS tag.
if base == DEFAULT_OS:
if base == DEFAULT_OS or opts.force_latest:
latest_default_os_tag = get_full_tag(opts.repository, target, 'latest', '')
tags.append(latest_default_os_tag)

Expand Down

0 comments on commit 56c0132

Please sign in to comment.