Optimise container images: multi-stage (size reuduction) & one process per container
Opened this issue · 0 comments
spwoodcock commented
Issue
Currently the web
container could be optimised in two ways:
- The size could be greatly reduced from 3.9GB to around 1.5GB using a multi-stage build.
- It has three processes inside the same container: the Rails server, cgimap, and Apache. This should ideally be split out to separate containers in line with best practices (one process per container, PID 1).
Solution
- Have already done the build optimisation for the rails server in hotosm/osm-sandbox.
- I also added a small script to build the cgimap image separately:
#!/bin/sh CGIMAP_VERSION=v2.0.0 docker build \ "https://github.com/zerebubuth/openstreetmap-cgimap.git#${CGIMAP_VERSION}" \ --file docker/debian/Dockerfile_bookworm \ --tag ghcr.io/hotosm/osm-sandbox/cgimap:${CGIMAP_VERSION}
- The webserver should run independently, routing to either the Rails server container, or cgimap container, depending on the route accessed. This could easily be changed to
nginx
fromApache
too.
I plan to contribute this change, as discussed a few months ago! Finally got time to work on this 😄