superfly / flyctl

Command line tools for fly.io services
https://fly.io
Apache License 2.0
1.42k stars 238 forks source link

Large files in working directory cause `fly deploy` to fail without explanation #1225

Open biqqles opened 2 years ago

biqqles commented 2 years ago

Bug description

I was trying to deploy a basic Ruby app using the build pack. Frustratingly, deployment would consistently hang before reaching the DETECTING phase as follows:

$ fly deploy
Deploying forumlancer
==> Validating app configuration
--> Validating app configuration done
Remote builder fly-builder-wild-firefly-684 ready
==> Building image with Buildpacks
--> docker host: 20.10.12 linux x86_64
20: Pulling from heroku/buildpacks
Digest: sha256:c2a17bfdf74103f3f964008aa4130364456014040a513d2546b398bc24109391
Status: Image is up to date for heroku/buildpacks:20
20-cnb: Pulling from heroku/heroku
Digest: sha256:b323808b41c13adafdeb0b546fe7fddeafe5695f573c1a3bd1e3aa5c3586b462
Status: Image is up to date for heroku/heroku:20-cnb

# after a very very long time of nothing
Error executing lifecycle: io: read/write on closed pipe

First of all I worked around this by writing a Dockerfile and avoiding the buildpack method. I was still puzzled about why the Ruby example in the docs worked yet my app didn't even get through deployment, Through further experimentation I figured out that the problem was caused by the presence of my vendor/bundle directory (containing locally installed gems), and that adding a .dockerignore file excluding vendor allowed me to use the buildpack.

Finally, I tested creating a file the same size as my vendor (140M). It also caused deployment to hang. Therefore my assumption is (reinforced by this) that the entire working directory is being uploaded and this is timing out with my slow connection.

Suggestions

Since installing packages in the working directory like this is fairly common (see above link), I think the DX could be improved by improving documentation (online and in the CLI). The utility of using .dockerignore with a buildpack app is mentioned in the docs for Node but not Ruby. This note would be good to add to the page for every language.

If the hang is simply due to a large upload that is timing out, then fly deploy itself could communicate that an upload is happening at this stage (perhaps even with a progress indicator) which would allow the developer to guess the problem. I originally thought this was either a bug with flyctl or your servers so I hope this can be improved.

Thanks for making Fly!

fly.toml

app = "forumlancer"

[build]
  builder = "heroku/buildpacks:20"

[processes]
  worker = "bundle exec ruby src/forumlancer.rb"

System information

redjonzaci commented 1 year ago

Hey @biqqles! Have you had this issue lately?