Skip to content

Commit

Permalink
release-docker: add registry option
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonadoni committed Oct 25, 2023
1 parent aa52593 commit 0306064
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions reana/reana_dev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ def release_commands():
)
@click.option("--user", "-u", default="reanahub", help="DockerHub user name [reanahub]")
@click.option("--image-name", help="Should the component have a custom image name?")
@click.option(

Check warning on line 87 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L87

Added line #L87 was not covered by tests
"--registry", "-r", default="docker.io", help="Registry to use in the image tag"
)
@release_commands.command(name="release-docker")
@click.pass_context
def release_docker(ctx, component, user, image_name): # noqa: D301
def release_docker(ctx, component, user, image_name, registry): # noqa: D301

Check warning on line 92 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L92

Added line #L92 was not covered by tests
"""Release a component on Docker Hub.
\b
Expand All @@ -108,18 +111,32 @@ def release_docker(ctx, component, user, image_name): # noqa: D301
:type component: str
"""
components = select_components(component)

if image_name and len(components) > 1:
click.secho("Cannot use custom image name with multiple components.", fg="red")
sys.exit(1)

Check warning on line 117 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L115-L117

Added lines #L115 - L117 were not covered by tests

cannot_release_on_dockerhub = []
for component_ in components:
if not is_component_dockerised(component_):
cannot_release_on_dockerhub.append(component_)
is_component_releasable(component_, exit_code=True, display=True)
full_image_name = f"{user}/{image_name or component_}"
# source_image_name is the name used by docker-build
source_image_name = f"docker.io/{user}/{component_}"
target_image_name = f"{registry}/{user}/{image_name or component_}"

Check warning on line 126 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L125-L126

Added lines #L125 - L126 were not covered by tests
docker_tag = get_docker_tag(component_)
run_command(
f"docker tag {full_image_name}:latest {full_image_name}:{docker_tag}",
f"docker tag {source_image_name}:latest {target_image_name}:{docker_tag}",
component_,
)
ctx.invoke(docker_push, component=[component_], tag=docker_tag, user=user)
ctx.invoke(

Check warning on line 132 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L132

Added line #L132 was not covered by tests
docker_push,
component=[component_],
registry=registry,
user=user,
image_name=image_name,
tag=docker_tag,
)

if cannot_release_on_dockerhub:
click.secho(
Expand Down

0 comments on commit 0306064

Please sign in to comment.