rye icon indicating copy to clipboard operation
rye copied to clipboard

Document expectations for usage in containers

Open DragoonAethis opened this issue 11 months ago • 3 comments

Various Python project management solutions have different approaches to being used within containers - some prefer just using the system-wide Python and its site-packages, others want system Python and packages in a virtualenv, while Rye generally prefers managing the entire world on its own. It'd be nice to document how users are expected to use Rye in combination with Docker, etc, so that people prefer a lightweight base system image instead of shipping Python multiple times, or are aware of config knobs useful in reproducible environments.

DragoonAethis avatar Feb 28 '24 22:02 DragoonAethis

There is now a basic document https://rye-up.com/guide/docker/ .

ischaojie avatar Mar 24 '24 05:03 ischaojie

There is now a basic document https://rye-up.com/guide/docker/ .

I'm a bit confused by that document, why is PYTHONDONTWRITEBYTECODE=1 needed?

IMHO, the pdm documentation is super great, and doesn't leave any build-time artifacts in the runtime Docker image: https://pdm-project.org/latest/usage/advanced/#use-pdm-in-a-multi-stage-dockerfile

gdamjan avatar Apr 25 '24 12:04 gdamjan

@gdamjan PYTHONDONTWRITEBYTECODE prevents .pyc bytecode cache files from being saved to the image - if set, this results in smaller images that take a little longer to start (= first package import takes longer). It's not required and you can drop it if you prefer faster startup, although on modern Python versions the difference is noticeable only for larger codebases, massive dependency trees or function-style services (think AWS Lambda, etc).

From what I see in the multi-stage build, the biggest difference is that the runtime version does not come with PDM installed. For Rye, since you're just using pip as provided by the base image, so there's nothing extra to remove.

DragoonAethis avatar Apr 25 '24 12:04 DragoonAethis