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

Optimise container images: multi-stage (size reuduction) & one process per container #338

Open
spwoodcock opened this issue Aug 19, 2024 · 0 comments

Comments

@spwoodcock
Copy link
Contributor

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 from Apache too.

I plan to contribute this change, as discussed a few months ago! Finally got time to work on this 😄

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

No branches or pull requests

1 participant