teemii icon indicating copy to clipboard operation
teemii copied to clipboard

Multi-stage build for backend

Open schklom opened this issue 1 year ago • 3 comments

Description

The backend Docker image is 1.49GB on my arm64 machine. I doubt the entire space is needed.

Desired Behavior

Although I don't know how to dev using npm, a quick search shows that multi-stage building the Docker image is possible: https://www.cloudnweb.dev/2019/10/crafting-multi-stage-builds-with-docker-in-node-js/

For this backend image, is something similar doable?

Additional Context

No response

Code of Conduct

  • [X] I agree to follow Teemii's Code of Conduct

schklom avatar Jan 07 '24 14:01 schklom

Yes, the image size is relatively important for the Teemii backend, particularly because of the presence of Puppeteer and therefore Chromium. The Docker Files are not optimized at the moment, but I'll look into implementing your suggestion. Many Thanks!

dokkaner avatar Jan 07 '24 23:01 dokkaner

To lighten it, you could stop embedding Puppeteer into the image, and add it as a container in the docker-compose.yml, then add a URL to it as an environment variable. Other projects such as https://github.com/dgtlmoon/changedetection.io use this service too and let the user run a dedicated Docker container for it. The benefit is that a Puppeteer container can be used by multiple other containers, instead of each one embedding a brand new Puppeteer.

schklom avatar Jan 08 '24 10:01 schklom

Yes, I had actually thought about it. But for the moment I'd prefer it to be integrated and dedicated to Teemii. Because even though it would bring more flexibility, it would require more configuration and considerations during setup on the part of the user, which I don't want at the moment.

dokkaner avatar Jan 08 '24 11:01 dokkaner