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

improve Dockerfile (resulting in much smaller Image) #261

Merged
merged 2 commits into from
Feb 2, 2025

Conversation

vordenken
Copy link
Contributor

@vordenken vordenken commented Jan 29, 2025

Hi @clusterzx ,

this PR has changes regarding the Dockerfile.

These changes result in a much smaller image (645MB instead of 1.37GB).
It also uses npm ci instead of npm install, which is recommended in CI builds.

I tested the build locally and it worked for me, but maybe a bit more testing would be good.

EDIT: I see that the NODE_ENV is defined in ecosystem.config.js already, so adding it to the Dockerfile would be redundant - could you explain what's the reason to use pm2?

@clusterzx
Copy link
Owner

Sorry for the late reply, PM2 is used to determine termination signals and restart the application. So when a setting is changed or install is done, a SIGTERM is sent and PM2 restarts the application so the app can reload the changed .env vars.

@clusterzx clusterzx merged commit 856ab77 into clusterzx:main Feb 2, 2025
@Daniel15
Copy link

Daniel15 commented Feb 2, 2025

Are python3, make, and g++ needed at runtime, or only at build time? If they're just build time dependencies, you could make the image even smaller by building in one, then copying the build artifacts to a new one that excludes all the dependencies only needed at build time. https://docs.docker.com/build/building/multi-stage/

@vordenken
Copy link
Contributor Author

Yes, a multi-stage-build would probably be even better/smaller. After this PR I started working on a version, but had a few issues and my time is limited atm.

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.

3 participants