Closed christophe-f closed 1 year ago
Currently, the majority of the dockerfile build time is allocated to running the fix-permissions
script. Is there a way we could cut down the time required to run this script? @sabre1041 @tumido
@schultzp2020 I think you can make the Dockerfile to use the fix-permissions
script earlier in multiple layers instead of just as the last one. What that would result into is incremental changes - container layers work in a way that they store all that is changed compared to the previous layer. So, if the fix-permissions
was already executed for some files, it means the permissions don't have to be updated for them again + these files are already cached in their final state in previous layers. This should potentially (and counterintuitively) result in smaller and faster builds.
@tumido I have yet to try it; however, I do not believe that will work because the last (prod) stage doesn't copy files directly from the build stage. Instead the build stage creates tarballs, which are then extracted during the prod stage. Therefore, the majority of the files are not from previous stages that would benefit from running fix-permissions
in an earlier stage.
I think tarball preserves permissions, doesn't it? Let's try it and if it doesn't work we can try to come up with something else... 🙂
End users will no longer be building their own backstage showcase images, so this issue is mainly for improving our own build times for showcase and RHDH.
Currently I have only identified optimizations for the first stage (dependency installations) by only copying package.json
files rather than the entire repository.
There are no optimizations we can do for the dockerfile since the fix-permissions
script takes the most amount of time and we do not control the script.
What do you want to improve?
Optimize Dockerfile to run faster. We have many contributions and it takes a long time to get feedback, merge and deploy.
What is the current behavior?
The build time was already too long and doubled in the last week.
What is the new behavior?
Build faster. Much faster
:warning: Is this a breaking change?
Put an
x
in the boxes that apply