Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile optimised #423

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

dishak
Copy link

@dishak dishak commented May 15, 2024

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 added 5 commits May 9, 2024 22:41
optimising docker file by shifting the layers up the file for caching.
This script file copies all package.json and yarn.lock file/s into their respective directories/sub directories in newly to be built docker image
@hkirat
Copy link
Collaborator

hkirat commented May 17, 2024

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?

@dishak
Copy link
Author

dishak commented May 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants