tilt-dev / tilt-extensions

Extensions for Tilt
https://tilt.dev/
Apache License 2.0
200 stars 156 forks source link

Building Docker Image Failing with 'restart_process' extension on Windows #544

Closed djhelmick closed 7 months ago

djhelmick commented 7 months ago

Tilt: v0.33.10, built 2023-12-15 System: windows-amd64

Beginning this afternoon, I've started seeing the below error when attempting to run my Tiltfile using the restart_process extension.

STEP 3/5 — Building Dockerfile: [***]
Building Dockerfile for platform linux/amd64:

  FROM tiltdev/restart-helper:2021-11-03 as restart-helper

  FROM localhost:63333/[***-tilt_docker_build_with_restart_base:tilt-612fc2746907dfe5
  RUN ["mkdir", "-p", "\tmp\.restart"]
  RUN ["touch", "/tmp/.restart/proc"]
  RUN ["chmod", "666", "/tmp/.restart/proc"]
  COPY --from=restart-helper /tilt-restart-wrapper /
  COPY --from=restart-helper /entr /
  ENTRYPOINT ["/tilt-restart-wrapper", "--watch_file=/tmp/.restart/proc", "dotnet", "[***.dll"]

     Building image
     [restart-helper 1/1] FROM docker.io/tiltdev/restart-helper:2021-11-03@sha256:74d89eac884107e73e2f947a72e702750c92b16e2fae3b1da1ac36c14e79c5ff
     [stage-1 1/6] FROM localhost:63333/[***-tilt_docker_build_with_restart_base:tilt-612fc2746907dfe5
     [stage-1 2/6] RUN ["mkdir", "-p", "\tmp\.restart"]
       → /bin/sh: 1: [mkdir,: not found

     ERROR IN: [stage-1 2/6] RUN ["mkdir", "-p", "\tmp\.restart"]

Build Failed: ImageBuild: process "/bin/sh -c [\"mkdir\", \"-p\", \"\\tmp\\.restart\"]" did not complete successfully: exit code: 127

I hadn't made any changes to the Tiltfile so at first I was at a bit of a loss as to why it suddenly started yelling about mkdir during this step. After looking through the repos, however, I noticed that the PR https://github.com/tilt-dev/tilt-extensions/pull/541 was accepted about an hour ago which adds in that RUN step.

image

I am running Tilt on Windows. I'm wondering if that call to os.path.dirname in the PR is maybe an issue because it returns a path containing backslashes on Windows instead of forward slashes? That windows-based path then tries to be used with mkdir during the dockerfile build, and it errors out there?

nicks commented 7 months ago

Hmmm that's odd. What are you using as a base image? The error doesn't have anything to do with Windows, it means you don't have 'mkdir' in the base image.

In any case, the PR has been rolled back

djhelmick commented 7 months ago

Hi @nicks , thank you! I've confirmed things are now working again after the rollback.

I'm not quite sure why the error manifests the way it does -- I agree it did initially look like mkdir was missing -- but the base image(s) from Tilt & basically any other that do for sure include mkdir lead to the same error if using a windows-based path that contains backslashes. And if you use a proper linux path instead with forward slashes, the error goes away.

I double-checked this just with a simple dockerfile that duplicates what the Tilt step was doing.

comparison

Not really an issue since it's been rolled back but just some more context if it's helpful!