hedgedoc / container

HedgeDoc container image resources
https://docs.hedgedoc.org/setup/docker/
195 stars 52 forks source link

Improve Container size #488

Closed mqus closed 9 months ago

mqus commented 9 months ago

I know this is probably not a priority but 500mb (talking about the uncompressed alpine image) is pretty large for an application with this scope. Of course, some of this is node and alpine, but hedgedoc itself takes up an impressive 350MB. ~215mb of this is node_modules and another 126MB is in the public folder.

I found some things that might reduce size (but I'm not a node expert at all, so take this with a grain of salt):

  1. source maps(*.map files). Imho they shouldn't be necessary in a production image and they alone take up ~40mb.
  2. fonts. Afaict all fonts together take up another 25mb. Of course you can't remove them all, but some fonts seem to be there twice and more, just because they are bundled from multiple dependencies. I imagine consolidation here can be hard if not impossible.
  3. .d.ts files. Afaik those are files from typescript type hints (again, not an expert at all). If i'm right, those are another ~50mb and they are not relevant for production use at all.
  4. miscellaneous files from the repository like .git, .github, .yarn, package.json, README.md, test and so on and so on. All of those aren't that big, but they really add to the clutter. A solution here could be to only really copy the relevant directories to the next build stage.
mqus commented 9 months ago

Of course, some or all of these may also be relevant to the main repo, I wasn't sure where to put it, but since my main issue is with the docker image, I opened it here.

davidmehren commented 9 months ago

This repository contains the HedgeDoc 1 image, which we are not going to invest much time in anymore, as we focus on developing HedgeDoc 2. See also https://github.com/hedgedoc/hedgedoc#state-of-the-project

Over at https://github.com/orgs/hedgedoc/packages?repo_name=hedgedoc you can find the images for the HedgeDoc 2 frontend and backend. These are about 280 MB each, of which about 130 MB should be shared layers. If you have any more suggestions about improving image size (Dockerfiles are in the frontend/docker and backend/docker folders in the main hedgedoc repo), please open an issue over there 😃

mqus commented 9 months ago

I'll take a look once it's finally released.