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

Rework Dockerfile to reduce image size #58

Merged
merged 1 commit into from
Oct 22, 2023
Merged

Conversation

dumbasPL
Copy link
Contributor

@dumbasPL dumbasPL commented Oct 17, 2023

Things that changed:

  • split the build process into two stages (added a separate build stage)
  • build the app in standalone mode. Based on this example
  • switched to using --chown=borgwarehouse:borgwarehouse to avoid an unmercenary copy that comes with a manual chown.
  • removed the git apt package (I wasn't able to find where it's used so I'm assuming it's not needed)
  • removed the apt upgrade command. IMO this should be done by just pulling a new version of the base image and rebuilding.
  • added extra files to .dockerignore to help with caching builds

I decided against trying to move away from the Debian base, so that's actually unchanged. Maybe I will make a separate alpine-based image later.

closes #57

@dumbasPL
Copy link
Contributor Author

Size reduction

  • compressed: from 408.6MB to 122.55MB
  • uncompressed: from 1.2GB to 393MB

@hugalafutro
Copy link

I've built the image with your changes and did an in-place upgrade of my setup and everything works and the image is 1/3rd of what it was.

@Ravinou Ravinou merged commit 957bba5 into Ravinou:main Oct 22, 2023
@Ravinou
Copy link
Owner

Ravinou commented Oct 22, 2023

Thank you very much @dumbasPL , I merged your changes and I'm building the new image to push it on dockerhub.

Thank you for testing it with me @hugalafutro 🙏

@dumbasPL
Copy link
Contributor Author

I'm building the new image to push it on dockerhub.

Automating that with GitHub actions would probably be a good idea 😉

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.

Reduce docker image size
3 participants