Building image takes a very long time

Hello everyone,

I’m currently facing an issue with the release process of my Django application on The process is taking an extremely long time, and I’m not sure why. I would appreciate any insights or suggestions on how to resolve this.

Here’s further information:

  • I’m using the flyctl deploy command to deploy my application.
  • The application is a Django project.

Here’s the (shortened) output from my terminal after the deployment was finished:

(.venv) [...] % flyctl deploy
==> Verifying app config
✓ Configuration is valid
--> Verified app config
==> Building image
Remote builder fly-builder-blue-voice-1089 ready
Remote builder fly-builder-blue-voice-1089 ready
==> Building image with Docker
--> docker host: 24.0.7 linux x86_64
[+] Building 1241.4s (13/13) FINISHED                                                          
 => [internal] load .dockerignore                                                         0.2s
 => => transferring context: 116B                                                         0.2s
 => [internal] load build definition from Dockerfile                                      0.2s
 => => transferring dockerfile: 724B                                                      0.2s
 => [internal] load metadata for              0.6s
 => [1/8] FROM  0.0s
 => [internal] load build context                                                      1231.3s
 => => transferring context: 677.01MB  

As you can see, the ‘load build context’ step is taking a significant amount of time (1241.4s, i.e. about 21 minutes). The size of the context being transferred is 677.01MB.

I’m not sure why this step is taking so long, as in the past this has not been the case, i.e. the release used to take a few minutes max. I had a couple of failed releases and ever since those arose the release process takes such a long time.

Thank you in advance for your assistance and please let me know if you need additional information.

I encourage you to review your .dockerignore file. You likely are uploading more than you need to. A problem made worse by the fact that many internet connections are asymmetrical – with better download speeds than upload.

If you are not sure, you can debug this by creating a file named Dockerfile.test with the following contents:

FROM ubuntu
COPY . .

Then run the following command:

fly console --dockerfile Dockerfile.test -C bash

Once you get a command prompt from the ephemeral machine that this creates, you can find where the problem is with the following command:

du -s * .* | sort -n

Thank you very much @rubys. I have solved the issue by uninstalling kolo. I am not sure whether this was the root cause but after having uninstalled it the build phase was significantly reduced again to a few minutes. Kolo is an interesting app to visualize function calls etc. and I would have loved to keep it but hey, you can’t have it all sometimes.

Thank you also for your suggestion regarding the .dockerignore file. Mine has the typical content such as .env, .git, .venv, pycache, .sqlite3 and I couldn’t find anything else to include that would have made a substantial difference.