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
Next Next commit
fix: docker buildx does not support --image parameter
  • Loading branch information
amimas committed Sep 26, 2026
commit 15f32fc5cacb700fbd4b03e5d69ea226fba23381
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,11 @@ jobs:
- name: Build image for PR validation
run: |
uv run --no-sync docker build \
--image ghcr.io/gitlabform/gitlabform \
--tag sha-${{ github.sha }}-${{ matrix.tag_suffix }} \
--platform ${{ matrix.platform }} \
--output type=docker,dest=.docker/${{ matrix.tarball }}
- name: Verify image
run: |
uv run --no-sync docker verify \
--image ghcr.io/gitlabform/gitlabform \
--tag sha-${{ github.sha }}-${{ matrix.tag_suffix }} \
--input .docker/${{ matrix.tarball }}
- name: Upload docker image archive
uses: actions/upload-artifact@v7
Expand Down
21 changes: 9 additions & 12 deletions dev/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ def build(extra_args: list[str] | None = None):
workflow.

Args:
extra_args: Arguments for the docker build command (e.g., --image, --tag, --push, --output).
extra_args: Arguments for the docker build command (e.g., --tag, --push, --output).
"""
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--image", default="localhost/gitlabform")
parser.add_argument("--tag", default="latest")
parser.add_argument("--tag", default="localhost/gitlabform:latest")
parser.add_argument("--push", action="store_true", help="Automatically push after build")
parser.add_argument(
"--output", help="Write the built image to an archive file (for example: type=docker,dest=/tmp/image.tar)"
)

parsed, remaining = parser.parse_known_args(extra_args or [])
image_name = f"{parsed.image}:{parsed.tag}"
# image_name = f"{parsed.tag}"

# Ensure the Docker build has access to the prebuilt wheel artifact.
dist_dir = REPO_ROOT / "dist"
Expand All @@ -41,28 +40,26 @@ def build(extra_args: list[str] | None = None):
raise SystemExit(1)

docker_bin = get_executable("docker")
build_cmd = [docker_bin, "buildx", "build", "--pull", "-t", image_name]
build_cmd = [docker_bin, "buildx", "build", "--pull", "-t", parsed.tag]
if parsed.output:
build_cmd.extend(["--output", parsed.output])
build_cmd.extend(remaining)
build_cmd.append(str(REPO_ROOT))

run_command(build_cmd, f"Building Docker image: [bold cyan]{image_name}[/bold cyan]")
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"--image={parsed.image}", f"--tag={parsed.tag}"])
publish_docker([f"--tag={parsed.tag}"])
Comment thread
rickbrouwer marked this conversation as resolved.
Outdated


def verify(extra_args: list[str] | None = None):
"""Verifies the built Docker image with a smoke test."""
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--image", default="localhost/gitlabform")
parser.add_argument("--tag", default="latest")
parser.add_argument("--tag", default="localhost/gitlabform:latest")
parser.add_argument("--input", help="Load a Docker image archive from disk before verifying it")

parsed, remaining = parser.parse_known_args(extra_args or [])
image_name = f"{parsed.image}:{parsed.tag}"

docker_bin = get_executable("docker")
if parsed.input:
Expand All @@ -73,5 +70,5 @@ def verify(extra_args: list[str] | None = None):
load_cmd = [docker_bin, "load", "--input", str(archive)]
run_command(load_cmd, f"Loading Docker image archive: [bold cyan]{archive}[/bold cyan]")

cmd = [docker_bin, "run", "--rm"] + remaining + [image_name, "gitlabform", "--version"]
run_command(cmd, f"Verifying Docker image: [bold cyan]{image_name}[/bold cyan]")
cmd = [docker_bin, "run", "--rm"] + remaining + [parsed.tag, "gitlabform", "--version"]
run_command(cmd, f"Verifying Docker image: [bold cyan]{parsed.tag}[/bold cyan]")
13 changes: 5 additions & 8 deletions dev/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,15 @@ 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("--image", default="localhost/gitlabform", help="Image name (default: localhost/gitlabform)")
b.add_argument("--tag", default="latest", help="Image tag (default: latest)")
b.add_argument("--tag", default="localhost/gitlabform:latest", help="Image tag (default: 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)"
)
b.add_argument("extra_args", nargs=argparse.REMAINDER, help="Additional arguments for docker build")

v = subparsers.add_parser("verify", help="Validate the image with a smoke test", description=DESC_DOCKER)
v.add_argument("--image", default="localhost/gitlabform", help="Image name (default: localhost/gitlabform)")
v.add_argument("--tag", default="latest", help="Image tag (default: latest)")
v.add_argument("--tag", default="localhost/gitlabform:latest", help="Image tag (default: latest)")
Comment thread
rickbrouwer marked this conversation as resolved.
Outdated
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 All @@ -145,7 +143,7 @@ def _dispatch_docker(args):
"""Executes Docker logic."""
# Reconstruct arguments to maintain compatibility with the backend parser
# and ensure that help/defaults defined in the CLI are respected.
extra_args = ["--image", args.image, "--tag", args.tag]
extra_args = ["--tag", args.tag]
if args.command == "build" and args.push:
extra_args.append("--push")
if args.command == "build" and getattr(args, "output", None):
Expand Down Expand Up @@ -183,8 +181,7 @@ 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("--image", default="localhost/gitlabform", help="Image name (default: localhost/gitlabform)")
docker_p.add_argument("--tag", default="latest", help="Image tag (default: latest)")
docker_p.add_argument("--tag", default="localhost/gitlabform:latest", help="Image tag (default: latest)")
docker_p.add_argument("extra_args", nargs=argparse.REMAINDER, help="Additional arguments for docker push")


Expand All @@ -196,7 +193,7 @@ def _dispatch_release(args):
run_publish_logic(args.extra_args)
elif args.command == "docker":
# Reconstruct arguments to maintain compatibility with the backend parser
extra_args = ["--image", args.image, "--tag", args.tag]
extra_args = ["--tag", args.tag]
if args.extra_args:
extra_args.extend(args.extra_args)
run_docker_push_logic(extra_args=extra_args)
Expand Down
2 changes: 1 addition & 1 deletion docs/contrib/local_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ This requirement is intentional: the `Dockerfile` installs the packaged wheel, i
You can customize the image name and tag via arguments:

```bash
uv run glf-dev docker build --image my-registry/gitlabform --tag dev
uv run glf-dev docker build --tag my-registry/gitlabform:dev
```

To see all Docker build options:
Expand Down