Skip to content

Commit

Permalink
Optionally tag images as latest (#8132)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsanders committed Jun 1, 2022
1 parent f2beff3 commit 217f636
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions python_modules/automation/automation/docker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def build_all(name: str, dagster_version: str, timestamp: str, platform: Optiona
required=True,
help="Version of image to push",
)
opt_set_latest = click.option(
"--set-latest",
is_flag=True,
default=False,
help="Whether to tag the image as latest",
)


@cli.command()
Expand Down Expand Up @@ -118,20 +124,26 @@ def push_to_registry(name: str, tags: List[str]) -> None:
@cli.command()
@opt_push_name
@opt_push_dagster_version
def push_dockerhub(name: str, dagster_version: str):
@opt_set_latest
def push_dockerhub(name: str, dagster_version: str, set_latest: bool):
"""Used for pushing k8s images to Docker Hub. Must be logged in to Docker Hub for this to
succeed.
"""

tags = [f"dagster/{name}:{dagster_version}", f"dagster/{name}:latest"]
tags = [
f"dagster/{name}:{dagster_version}",
]
if set_latest:
tags.append(f"dagster/{name}:latest")

push_to_registry(name, tags)


@cli.command()
@opt_push_name
@opt_push_dagster_version
def push_ecr(name: str, dagster_version: str):
@opt_set_latest
def push_ecr(name: str, dagster_version: str, set_latest: bool):
"""Used for pushing k8s images to our public ECR.
You must be authed for ECR. Run:
Expand All @@ -141,8 +153,9 @@ def push_ecr(name: str, dagster_version: str):

tags = [
f"{AWS_ECR_REGISTRY}/{name}:{dagster_version}",
f"{AWS_ECR_REGISTRY}/{name}:latest",
]
if set_latest:
tags.append(f"{AWS_ECR_REGISTRY}/{name}:latest")

push_to_registry(name, tags)

Expand Down

0 comments on commit 217f636

Please sign in to comment.