Skip to content

[image-spec]: revert nix-native image builder (#35) and cross-build support (#43)#45

Open
jld-adriano wants to merge 2 commits intomasterfrom
devin/1771912775-revert-pr-35
Open

[image-spec]: revert nix-native image builder (#35) and cross-build support (#43)#45
jld-adriano wants to merge 2 commits intomasterfrom
devin/1771912775-revert-pr-35

Conversation

@jld-adriano
Copy link

@jld-adriano jld-adriano commented Feb 24, 2026

Tracking issue

Reverts #35 and #43.

Why are the changes needed?

Reverting the nix-native image builder changes (#35) and the cross-build support (#43, which depended on #35) per request. This restores the previous depot-based build path for nix=True ImageSpec builds.

What changes were proposed in this pull request?

Two git revert -m 1 operations in reverse chronological order:

  1. Revert of feat(image-spec): add cross-platform nix build support via remote builders #43 (cross-platform nix build support via remote builders)
  2. Revert of [image-spec]: nix-native image builder, churn depot dependency #35 (nix-native image builder, churn depot dependency)

This restores:

  • use_depot default back to True
  • NIX_DOCKER_FILE_TEMPLATE (Docker-in-Docker approach: installs nix inside Ubuntu container, runs nix run .#docker.copyTo)
  • Depot-based build path when nix=True (uses --project bf5bv9t2mj)
  • Original error messages suggesting use_depot=True as alternative
  • run(command, check=True) instead of manual returncode + credential redaction

How was this patch tested?

Mechanical revert of two merge commits. Existing unit tests updated to match restored error messages.

⚠️ Human review checklist

Related PRs


Link to Devin run: https://app.devin.ai/sessions/af4653767caf4f7aa96c81f4244e94a6
Requested by: @jld-adriano


Open with Devin

…uild-support"

This reverts commit f31e414, reversing
changes made to 9ae5fe4.
…09-churn-depot"

This reverts commit b886c57, reversing
changes made to d08a784.
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines +197 to +199
nix run .#docker.copyTo -- docker://$IMAGE_NAME --dest-creds "AWS:$ECR_TOKEN" \
--image-parallel-copies 32 \
--dest-creds "AWS:$ECR_TOKEN"

Choose a reason for hiding this comment

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

🟡 Duplicate --dest-creds flag in NIX_DOCKER_FILE_TEMPLATE

The NIX_DOCKER_FILE_TEMPLATE passes --dest-creds "AWS:$ECR_TOKEN" twice to the nix run .#docker.copyTo command.

Root Cause

At flytekit/image_spec/default_builder.py:197-199, the template contains:

nix run .#docker.copyTo -- docker://$IMAGE_NAME --dest-creds "AWS:$ECR_TOKEN" \
--image-parallel-copies 32 \
--dest-creds "AWS:$ECR_TOKEN"

The --dest-creds argument appears on both line 197 and line 199. Depending on how skopeo (the underlying tool for copyTo) handles duplicate flags, this could cause unexpected behavior or errors. At minimum it's redundant; at worst it could cause authentication failures if the tool doesn't handle duplicate credential flags gracefully.

Impact: Every nix-based image build will pass duplicate credential flags to the copy tool.

Suggested change
nix run .#docker.copyTo -- docker://$IMAGE_NAME --dest-creds "AWS:$ECR_TOKEN" \
--image-parallel-copies 32 \
--dest-creds "AWS:$ECR_TOKEN"
nix run .#docker.copyTo -- docker://$IMAGE_NAME --dest-creds "AWS:$ECR_TOKEN" \
--image-parallel-copies 32
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines 773 to +783
if image_spec.nix:
return
docker_content = NIX_DOCKER_FILE_TEMPLATE.substitute(
IMAGE_NAME=image_spec.image_name(),
COPY_LOCAL_PACKAGES=copy_local_packages,
ECR_TOKEN=subprocess.run(
["aws", "ecr", "get-login-password", "--region", "us-west-2"],
capture_output=True,
text=True,
check=True,
).stdout.strip(),
)

Choose a reason for hiding this comment

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

🔴 ECR token fetched unconditionally in create_docker_context for nix builds, even when not pushing

create_docker_context always calls aws ecr get-login-password when nix=True, even when the build is local-only (push=False) or has no registry configured.

Root Cause

At flytekit/image_spec/default_builder.py:773-782, the nix branch unconditionally runs:

ECR_TOKEN=subprocess.run(
    ["aws", "ecr", "get-login-password", "--region", "us-west-2"],
    capture_output=True, text=True, check=True,
).stdout.strip(),

This is called from _build_image at line 883 via create_docker_context(image_spec, tmp_path) — the push parameter is not passed through. In the previous code (before the revert), the ECR token was only fetched when push and image_spec.registry was true (flytekit/image_spec/default_builder.py:826-829 in the old code).

This means:

  1. Running _build_image(spec, push=False) with nix=True will fail with a CalledProcessError if AWS CLI isn't configured, even though no push is intended.
  2. Running with nix=True but no ECR registry will also unnecessarily fail.
  3. The ECR token is baked into the Dockerfile as plaintext, which is a credential exposure risk (the token is written to disk and embedded in Docker build layers).

Impact: Nix builds are broken for local-only testing (push=False) and for non-ECR registries. Additionally, ECR credentials are exposed in the Dockerfile on disk.

Prompt for agents
In flytekit/image_spec/default_builder.py, the create_docker_context function at line 773-783 unconditionally fetches an ECR token when nix=True. This should be conditional on whether a push is actually needed and whether the registry is ECR. However, create_docker_context does not receive the push parameter. The fix requires either: (1) passing a push parameter to create_docker_context and only fetching the ECR token when push=True and the registry is ECR, or (2) moving the ECR token fetching logic out of create_docker_context and into _build_image where the push parameter is available, and passing it as a parameter to the template substitution. Additionally, consider using Docker build secrets (--secret) instead of embedding the token in the Dockerfile to avoid credential exposure.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +868 to +879
try:
result = run(["docker", "info"], capture_output=True, text=True)
if result.returncode != 0:
raise RuntimeError(
f"Docker daemon is not running or not accessible. Error: {result.stderr}\n"
"Please start Docker daemon or use depot by setting use_depot=True"
)
except Exception as e:
raise RuntimeError(
f"Failed to check Docker daemon status: {str(e)}\n"
"Please ensure Docker is properly installed and running, or use depot by setting use_depot=True"
)

Choose a reason for hiding this comment

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

🟡 except Exception catches and re-wraps the RuntimeError raised for non-running Docker daemon

When the Docker daemon check fails (returncode != 0), the specific RuntimeError is caught by the broad except Exception handler and re-raised with a less informative message.

Root Cause

At flytekit/image_spec/default_builder.py:868-879:

try:
    result = run(["docker", "info"], capture_output=True, text=True)
    if result.returncode != 0:
        raise RuntimeError(
            f"Docker daemon is not running or not accessible. Error: {result.stderr}\n"
            "Please start Docker daemon or use depot by setting use_depot=True"
        )
except Exception as e:
    raise RuntimeError(
        f"Failed to check Docker daemon status: {str(e)}\n"
        "Please ensure Docker is properly installed and running, or use depot by setting use_depot=True"
    )

When result.returncode != 0, the RuntimeError at line 871 is raised inside the try block. This is immediately caught by except Exception as e at line 875, and a new RuntimeError is raised wrapping the original. The user sees a confusing double-wrapped message like:

Failed to check Docker daemon status: Docker daemon is not running or not accessible. Error: ...
Please start Docker daemon or use depot by setting use_depot=True
Please ensure Docker is properly installed and running, or use depot by setting use_depot=True

The except block was intended to catch errors from run() itself (e.g., FileNotFoundError), not from the explicit RuntimeError raise.

Impact: Users see a confusing, double-wrapped error message when Docker daemon is not running.

Suggested change
try:
result = run(["docker", "info"], capture_output=True, text=True)
if result.returncode != 0:
raise RuntimeError(
f"Docker daemon is not running or not accessible. Error: {result.stderr}\n"
"Please start Docker daemon or use depot by setting use_depot=True"
)
except Exception as e:
raise RuntimeError(
f"Failed to check Docker daemon status: {str(e)}\n"
"Please ensure Docker is properly installed and running, or use depot by setting use_depot=True"
)
# Check if Docker daemon is running
try:
result = run(["docker", "info"], capture_output=True, text=True)
except Exception as e:
raise RuntimeError(
f"Failed to check Docker daemon status: {str(e)}\n"
"Please ensure Docker is properly installed and running, or use depot by setting use_depot=True"
)
if result.returncode != 0:
raise RuntimeError(
f"Docker daemon is not running or not accessible. Error: {result.stderr}\n"
"Please start Docker daemon or use depot by setting use_depot=True"
)
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

2 participants