Skip to content

feat(jig): jig deploy --image - #380

Open
dulaj-me wants to merge 3 commits into
nextfrom
dulaj-me/eng-87040-improve-dx-for-pushing-arbitrary-images
Open

feat(jig): jig deploy --image#380
dulaj-me wants to merge 3 commits into
nextfrom
dulaj-me/eng-87040-improve-dx-for-pushing-arbitrary-images

Conversation

@dulaj-me

Copy link
Copy Markdown
Contributor

src/together/lib/cli/api/beta/jig/jig.py

  1. Jig.push() (line 670): added source_image param. If set with empty tag, derives tag from source image (default "latest"). Branches to docker tag + docker push instead of buildx.
  2. push() wrapper (line ~1190): forwards source_image.
  3. push_cli() (line ~1458): adds --image flag, tag default → None. Passes "latest" when no image specified, "" (meaning "derive from source") when image specified without explicit tag.

Usage:

jig push                                  # builds & pushes to <upstream>:latest
jig push --tag v1                         # builds & pushes to <upstream>:v1
jig push --image myapp:dev                # retags & pushes <upstream>:dev
jig push --image myapp:dev --tag prod     # retags & pushes <upstream>:prod
jig push --image myapp                    # retags & pushes <upstream>:latest

Comment on lines +682 to +685
if source_image:
if subprocess.run(["docker", "tag", source_image, image]).returncode != 0:
raise JigError(f"Failed to retag {source_image}")
ok = subprocess.run(["docker", "push", image]).returncode == 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you test if this works properly with zstd compressed images? docker push might recompress the image as gzip before push

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
Tbh, I haven't tested this at all. I wanted to make sure if we're all ok with the UX

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. However it might be bit slow because we have to write the oci layout in a tmp dir and load it back to buildkit

@dulaj-me
dulaj-me force-pushed the dulaj-me/eng-87040-improve-dx-for-pushing-arbitrary-images branch from d599181 to 090d875 Compare July 23, 2026 10:42
@dulaj-me
dulaj-me changed the base branch from main to next July 23, 2026 10:42
@broly-code-security-scanner

broly-code-security-scanner Bot commented Jul 23, 2026

Copy link
Copy Markdown

Broly Security Scan

Note

Clean scan
No vulnerabilities detected in this PR.

Note

Re-scan this PR anytime with /broly scan — useful after /broly undismiss, or to refresh findings without a new push.

Broly — SAST (zai-org/GLM-5.2) · Secrets · SCA · GH Actions (zizmor) · Containers · SBOM · Powered by Together AI

docker push through a legacy (non-containerd) image store recompresses
layers as gzip, losing the zstd cold-start benefit. Instead, export the
source image as an OCI layout (docker save) and rebuild it through the
zstd builder with force-compression, re-encoding every layer as zstd.

- extract shared _buildx_push helper (was duplicated in push and
  build_and_push, would have been a third copy here)
- --image pushes now write the buildx metadata file, so
  image_with_digest works without relying on docker inspect RepoDigests
- JIG_DISABLE_BUILDX keeps the plain docker tag + docker push path
Comment thread src/together/lib/cli/api/beta/jig/jig.py Fixed
@dulaj-me
dulaj-me marked this pull request as ready for review July 23, 2026 11:35
Comment thread src/together/lib/cli/api/beta/jig/jig.py Outdated
layout = Path(tmp) / "oci"
layout.mkdir()
console.print(f"Exporting {source_image}")
save = subprocess.Popen(["docker", "save", source_image], stdout=subprocess.PIPE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think docker save is the really slow one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just piped to untar to make it bit faster. Not sure if there any other way to get the image to buildkit context

digest = json.loads(index.read_text())["manifests"][0]["digest"]
ctx = Path(tmp) / "ctx"
ctx.mkdir()
(ctx / "Dockerfile").write_text("FROM source-image\n")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's sufficient to do f"FROM {source_image}" with force-compression=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even

ARG SOURCE_IMAGE
FROM ${SOURCE_IMAGE}
docker buildx build \
  --file Dockerfile.recompress \
  --build-arg SOURCE_IMAGE=registry.example.com/team/app:gzip \
  --pull \
  --output type=registry,name=...:zstd,compression=zstd,compression-level=10,force-compression=true,oci-mediatypes=true \
  .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean for remote registry hosted images? I don't think you can do this with local images.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no you can

Comment thread src/together/lib/cli/api/beta/jig/jig.py Outdated
Comment thread src/together/lib/cli/api/beta/jig/jig.py Outdated
Comment thread src/together/lib/cli/api/beta/jig/jig.py Outdated
Comment thread src/together/lib/cli/api/beta/jig/jig.py Outdated
Co-authored-by: technillogue <wisepoison@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants