Slow Builds#
When looking at the logs for a build in the dashboard, each step will have a duration listed next to it like so.
Image Builds (Duration: 00:00:05)
When trying to identify why a build may be slow, it is worth checking for steps that have long duration and checking against the following sections to see if they may relate to where you're seeing an issue.
Image Builds or Image Push to Registry#
Most slow builds occur during the Image Build
or Image Push to Registry
phases of a build. Usually this is because of one or both of the reasons below.
See Dockerfile Best Practicies for some information to help build efficient images.
No or Low cache usage#
The first time an image is built, if there is no cache available then it can take some time to build images.
Subsequent builds may be faster depending on how your Dockerfiles are written to maximise how much the layers can be cached.
Search for ---> Using cache
in the logs to find when cache is used during your builds. An example of how it could look is below.
Step 2/3 : COPY file1 /app/.
---> Using cache
---> 94db40390e9d
Step 3/3 : COPY file2 /app/.
---> Using cache
---> 066f1837791a
If you see that you're very rarely using cache, then you may be able to benefit from optimising your Dockerfiles.
Images are too large#
This will result in the images taking a long time to build, but also a long time to push to the container registry. All builds will report the size of images that are built, search for Built image sizes
in the logs to find the size. An example of how this appears is below.
##############################################
Built image sizes:
##############################################
Image my-project-example-environment-nginx 139MB
If you see that your images are quite large, generally 1GB or larger, then you may be able to benefit from optimising your Dockerfiles to reduce the size of your images.
Pre or Post Rollout tasks#
Another place where builds may be slow is during pre or post rollout tasks. When there is an issue here, it may also appear like the build is "stuck".
Usually these tasks appear like this due to tasks like cloning a large database, or rsyncing a large set of files. If you regularly see slowness in these tasks, you may want to think about reducing the amount of data that is being transferred. If that isn't possible, then there is not much else that can be done.
Contact Support#
If you still aren't sure why its slow, contact support. Make sure you provide a link to the build log from the dashboard when submitting your request.