daily-code icon indicating copy to clipboard operation
daily-code copied to clipboard

Dockerfile optimised

Open dishak opened this issue 1 year ago • 2 comments

PR Fixes:

  • 1 Optimised the dockerfile for lesser build time. Attaching screenshot of build time with and without optimisation. My explainantion: w/o optimisation if any change in codebase, and rerunning of docker compose watch triggers yarn run install which can be easily cached thereby saving build time.

w/o optimisation

Screenshot from 2024-05-15 21-02-36

with optimisation (updated dockerfile and a script file(copyalljson.sh) which copies all package.json , yarn.lock files from all directories & subdirectories and pastes into destination equivalent directories within the docker container)

Screenshot from 2024-05-15 21-19-13

Checklist before requesting a review

  • [ ] I have performed a self-review of my code
  • [ ] I assure there is no similar/duplicate pull request regarding same issue

dishak avatar May 15 '24 19:05 dishak

Sorry but would this rebuild the copyalljson layer if package.json is actually changed? Since the script (sh file) hasn't changed, would it forget to re-build the layer and include the old package.json?

Is this standard pattern you saw somewhere?

hkirat avatar May 17 '24 17:05 hkirat

Sorry but would this rebuild the copyalljson layer if package.json is actually changed? Since the script (sh file) hasn't changed, would it forget to re-build the layer and include the old package.json?

Is this standard pattern you saw somewhere?

Yes you were right that copyalljson layer wasn't changing and infact the script which executed during image building was actually not copying the parent directory files as docker doesnt allow the script files(using RUN command) during build to access the parent directory filesystems. But, I have update dockerfile to just copy all package.json files and do run yarn install and deleted the script file.

dishak avatar May 19 '24 09:05 dishak