Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(dev): stop duplicating Docker image name on push
  • Loading branch information
amimas committed Oct 2, 2026
commit e1f2c26ba2458820960aab61ed95042bc8e986a2
4 changes: 2 additions & 2 deletions dev/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def build(extra_args: list[str] | None = None):
run_command(build_cmd, f"Building Docker image: [bold cyan]{parsed.tag}[/bold cyan]")

if parsed.push:
# Delegate to the release domain to ensure consistent push logic
publish_docker([f"--tag={parsed.tag}"])
# The build already resolved the image reference; pass it through as-is.
publish_docker(parsed.tag)


def verify(extra_args: list[str] | None = None):
Expand Down
22 changes: 14 additions & 8 deletions dev/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ def _dispatch_package(args):
def _add_docker_subcommands(subparsers):
"""Configures Docker image management commands."""
b = subparsers.add_parser("build", help="Build the production Docker image", description=DESC_DOCKER)
b.add_argument("--tag", default="localhost/gitlabform:latest", help="Image tag (default: latest)")
b.add_argument(
"--tag",
default="localhost/gitlabform:latest",
help="Docker image reference (default: localhost/gitlabform:latest)",
)
b.add_argument("--push", action="store_true", help="Push the image to the registry")
b.add_argument(
"--output", help="Write the built image to an archive file (for example: type=docker,dest=/tmp/image.tar)"
Expand All @@ -135,7 +139,9 @@ def _add_docker_subcommands(subparsers):

v = subparsers.add_parser("verify", help="Validate the image with a smoke test", description=DESC_DOCKER)
v.add_argument(
"--tag", default="localhost/gitlabform:latest", help="Image tag (default: localhost/gitlabform:latest)"
"--tag",
default="localhost/gitlabform:latest",
help="Docker image reference (default: localhost/gitlabform:latest)",
)
v.add_argument("--input", help="Load a Docker image archive from disk before verifying it")
v.add_argument("extra_args", nargs=argparse.REMAINDER, help="Additional arguments for docker run")
Expand Down Expand Up @@ -183,7 +189,11 @@ def _add_release_subcommands(subparsers):
help="Push the Docker image to a registry",
description="Push the built Docker image to the configured registry (e.g., GHCR).",
)
docker_p.add_argument("--tag", default="localhost/gitlabform:latest", help="Image tag (default: latest)")
docker_p.add_argument(
"--tag",
default="localhost/gitlabform:latest",
help="Docker image reference (default: localhost/gitlabform:latest)",
)
docker_p.add_argument("extra_args", nargs=argparse.REMAINDER, help="Additional arguments for docker push")


Expand All @@ -194,11 +204,7 @@ def _dispatch_release(args):
elif args.command == "pypi":
run_publish_logic(args.extra_args)
elif args.command == "docker":
# Reconstruct arguments to maintain compatibility with the backend parser
extra_args = ["--tag", args.tag]
if args.extra_args:
extra_args.extend(args.extra_args)
run_docker_push_logic(extra_args=extra_args)
run_docker_push_logic(args.tag)


def _add_infra_subcommands(subparsers):
Expand Down
17 changes: 7 additions & 10 deletions dev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,15 @@ def publish_pypi(extra_args: list[str] | None = None):
run_command(["uv", "publish"] + (extra_args or []), "Publishing package to PyPI")


def publish_docker(extra_args: list[str] | None = None):
"""Pushes the built Docker image to a registry.
def publish_docker(image_name: str | None = None):
"""Pushes a Docker image to a registry.

Args:
extra_args: Arguments for the docker push command (e.g., --image, --tag).
The image reference is resolved by the caller (for example, from the Docker build
command's tag) and passed through as a single value. This keeps the CLI consistent
with Docker's own image-reference semantics and avoids reconstructing tags from
separate image/name arguments.
"""
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--image", default="localhost/gitlabform")
parser.add_argument("--tag", default="latest")

parsed, remaining = parser.parse_known_args(extra_args or [])
image_name = f"{parsed.image}:{parsed.tag}"
image_name = image_name or "localhost/gitlabform:latest"
docker_bin = get_executable("docker")

run_command([docker_bin, "push", image_name], f"Pushing Docker image: [bold cyan]{image_name}[/bold cyan]")
Loading