Skip to content

Refactor docker #8

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

Merged
merged 2 commits into from
Jun 24, 2024
Merged

Refactor docker #8

merged 2 commits into from
Jun 24, 2024

Conversation

deltaroe
Copy link

@deltaroe deltaroe commented Jun 21, 2024

  • Use local checkout instead of pulling from git during build
  • Rearrange yarn installs and package.json copies to make more efficient docker layers.
    • Separate the node module installs into their own layers. They're less likely to change vs the rest of the node code.
    • This means multiple builds that don't change the dependencies don't need to reinstall the modules
  • Don't use nodemon inside the docker container
    • It doesn't really make sense since the files don't change in a built container
    • This also resolves a fun issue I had with lots of attachments causing the container to run out of inotify watches
  • Set PM2_HOME value
    • Otherwise it defaults to HOME which in this case is /data/db. If the mongo db directory is mounted externally and that mount doesn't support socket files (Thanks Azure Container Instances /s) it blows up as pm2 uses socket files

Use local checkout instead of pulling from git during build
Rearrange yarn installs and package.json copies to make more efficent docker layers.
  Separate the node module installs into their own layers. They're less likely to change vs the rest of the node code.
  This means multiple builds that don't change the dependencies don't need to reinstall the modules
Don't use nodemon inside the docker container
  It doesn't really make sense since the files don't change in a built container
  This also resolves a fun issue I had with lots of attachments causing the container to run out of inotify watches
@hppanpaliya hppanpaliya merged commit 8625721 into hppanpaliya:main Jun 24, 2024
@hppanpaliya
Copy link
Owner

Thanks for your contribution, @deltaroe. These Docker optimizations are impressive. I’m excited to see how separating the node module installs and removing nodemon inside the container will streamline our builds. The pm2_home setting fix is a valuable lesson. Thanks for sharing these improvements!

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