[GH-ISSUE #339] Separate layers in dockerfile to improve image build #125

Closed
opened 2026-03-16 13:35:01 +03:00 by kerem · 3 comments
Owner

Originally created by @vitorcx on GitHub (Nov 26, 2019).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/339

Originally assigned to: @vitorcx on GitHub.

Is your feature request related to a problem? Please describe.
The problem is related to the efficiency in the nodejs image building process when we choose to develop/contribute using docker-compose.
I realized that in the current dockerfile there is only one layer responsible for copying all code from the current directory into the container. This results in the need to rebuild the image from this layer whenever any part of the code is changed, which can lead to unnecessary waiting for the npm install process in cases where dependencies have not changed.

Describe the solution you'd like
One possible way to solve this is to separate the layers where the source code and package.json / package-lock.json are copied into the container. Also, copy the remaining source code only after the npm install process. Thus the dependencies will only be reinstalled when new dependencies are changed / added.

Describe alternatives you've considered
Another possibility of improvement is the addition of a docker-compose volume containing the source code, this would allow behavior similar to a hot reloading.

Additional context
Of course, all these suggestions made here are subject to discussion, because I may not be fully aware of the reasons why they are not currently implemented, even though they seems to be simple.

Originally created by @vitorcx on GitHub (Nov 26, 2019). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/339 Originally assigned to: @vitorcx on GitHub. **Is your feature request related to a problem? Please describe.** The problem is related to the efficiency in the nodejs image building process when we choose to develop/contribute using docker-compose. I realized that in the current dockerfile there is only one layer responsible for copying all code from the current directory into the container. This results in the need to rebuild the image from this layer whenever any part of the code is changed, which can lead to unnecessary waiting for the `npm install` process in cases where dependencies have not changed. **Describe the solution you'd like** One possible way to solve this is to separate the layers where the source code and package.json / package-lock.json are copied into the container. Also, copy the remaining source code only after the `npm install` process. Thus the dependencies will only be reinstalled when new dependencies are changed / added. **Describe alternatives you've considered** Another possibility of improvement is the addition of a docker-compose volume containing the source code, this would allow behavior similar to a hot reloading. **Additional context** Of course, all these suggestions made here are subject to discussion, because I may not be fully aware of the reasons why they are not currently implemented, even though they seems to be simple.
kerem 2026-03-16 13:35:01 +03:00
Author
Owner

@liyasthomas commented on GitHub (Nov 26, 2019):

why they are not currently implemented, even though they seems to be simple.

Because I'm a Docker noob. I'm new to Docker and all it's functionalities. It would be great if you could shoot up a PR! I'm still learning Docker, I'll review and merge to master 👍

<!-- gh-comment-id:558431555 --> @liyasthomas commented on GitHub (Nov 26, 2019): > why they are not currently implemented, even though they seems to be simple. Because I'm a Docker noob. I'm new to Docker and all it's functionalities. It would be great if you could shoot up a PR! I'm still learning Docker, I'll review and merge to master 👍
Author
Owner

@vitorcx commented on GitHub (Nov 26, 2019):

why they are not currently implemented, even though they seems to be simple.

Because I'm a Docker noob. I'm new to Docker and all it's functionalities. It would be great if you could shoot up a PR! I'm still learning Docker, I'll review and merge to master

Thanks for replying, i will do it then! It will be a pleasure to help.

<!-- gh-comment-id:558435483 --> @vitorcx commented on GitHub (Nov 26, 2019): > > why they are not currently implemented, even though they seems to be simple. > > Because I'm a Docker noob. I'm new to Docker and all it's functionalities. It would be great if you could shoot up a PR! I'm still learning Docker, I'll review and merge to master Thanks for replying, i will do it then! It will be a pleasure to help.
Author
Owner

@liyasthomas commented on GitHub (Nov 26, 2019):

#340 solves this hence closing

<!-- gh-comment-id:558442942 --> @liyasthomas commented on GitHub (Nov 26, 2019): #340 solves this hence closing
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#125
No description provided.