fly deploy not working from symlink

Took me quite a while to figure it out, so I wanted to share and hopefully this could get fixed.

For my project, using fly deploy fails with an error message that doesn’t help much. I put the error message below. (takes like 2 secs to fail)

I finally figured out that maybe it could be because in my Ubuntu 22.04 terminal, I use a symlink to reach my project’s directory.

Sure enough, when I went to the actual directory without symlinks in the path, fly deploy worked!

Hopefully this can be fixed from’s side

Leaving this here in case someone searches for parts of the error message, it may help them.

$ fly deploy
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-green-violet-3464 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
Sending build context to Docker daemon     144B
[+] Building 0.0s (2/2) FINISHED                                                                                                                                                                                   
 => CACHED [internal] load remote build context                                                                                                                                                               0.0s
 => CACHED copy /context /                                                                                                                                                                                    0.0s
Error failed to fetch an image or build from source: error building: failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /data/docker/tmp/buildkit-mount335201529/Dockerfile: no such file or directory

Do you have docker installed locally to try to do fly deploy --local-only (which will use your local Docker to build the image).

I suspect the symlink issue is that the remote builder attempts to follow the symlink but doesn’t find the file since the path it’s given doesn’t exist within the remote builder.

If that’s the case, I’m not sure that’s an issue flyctl can necessarily fix. I would guess it’s more related to how Docker runs builds than something in flyctl.

To clarify, the symlink is not inside the project.

My solution is the equivalent of just running cd $(realpath .) before doing the fly deploy.

If this really cannot be done from fly, then the situation could be detected by it and explained, saving headaches from customers.

Oh interesting - thanks for clarifying. That would take a bit more investigation to see if my theory is correct then :thinking:

Sounds like this has been hit before, so I believe you’re correct and that should get documented. I’ll add something to the docs for fly deploy.

This should be fixed via Resolve symlinks when building Docker context by wjordan · Pull Request #1373 · superfly/flyctl · GitHub

I confirm, I just tested with the latest flyctl version and it works. Thank you!

1 Like