Reduce Image Size and add new Alpine based Image
Description:
This PR refines the Dockerfile by splitting the build and release stages into separate images to reduce dependency noise. The build stage is now isolated, ensuring the release image is cleaner and more lightweight. Additionally, the node_modules directory is no longer copied, as the server has already been built, making that step unnecessary.
To further optimize the image size, a new Dockerfile is introduced based on Alpine. This version is a smaller image that uses Alpine-specific commands instead of Debian commands, ensuring reduced size without sacrificing functionality.
Result:
docker image ls | grep grimoire
thegameprofi/grimoire alpine 88b2537f2420 15 minutes ago 95.4MB
thegameprofi/grimoire latest c9abcecaabb6 19 minutes ago 227MB
goniszewski/grimoire latest d7724382aafb 6 weeks ago 875MB
Changes:
- Multi-stage Dockerfile: Split the process into separate images using FROM in different stages.
- Build Stage: Contains dependencies and build steps.
- Release Stage: Contains only the necessary release files, reducing the final image size.
- Removed node_modules copy: Since the server is already built, there's no need to include node_modules.
- Added Alpine-based Dockerfile: This image uses Alpine as the base, with equivalent Debian commands converted for compatibility.
Please retry analysis of this Pull-Request directly on SonarQube Cloud
I tested it locally and both worked normally. 👍
