Skip to content

[docker] Proposal: modernize Dockerfile (multi-stage) #144

Description

@yanissrairi

Hi,

The current Dockerfile works, but pip install ./bindings/python recompiles the C++ extension inside the final image, which means the runtime image carries the whole toolchain (g++, cmake, python3-dev). I'd like to split it into a real multi-stage build: a builder that produces a wheel, and a slim runtime that just installs it. Should bring the image size down meaningfully.

While I'm at it, a few smaller cleanups I'd bundle in or skip depending on your preference:

  • Bump the base to ubuntu:24.04 LTS (22.04 still works, just buys ~2 more years of support).
  • Run as a non-root user: mostly so files written to mounted volumes don't end up owned by root on the host.
  • BuildKit cache mounts for apt/pip: mainly speeds up CI rebuilds.

A couple of questions before I open a PR:

  1. The non-root switch slightly changes how mounted volumes behave. OK with you?
  2. tools/devops/Dockerfile.base and Dockerfile.multistage look like older WIP attempts (their readme even points to a wrong path). Leave them, clean up here, or separate PR?

Happy to drop any of the secondary items if you'd rather keep the change minimal.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions