Repository navigation
Docker venv - #8502
Docker venv#8502SchrodingersGat wants to merge 3 commits into
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
There was a problem hiding this comment.
Thank you very much for investigating this. This could indeed fix the issues. I will have to take a closer look and test this myself the next days. This may also explain the <property xxx> strings shown instead of the plugin names, but not sure about that one.
env -> venv
|
It does not appear to by working correctly yet, as the server runs system python and invoke binnaries ( A fully functional solution might be a ltitle trickier here. What we want is for: a) All base-level packages are installed into the docker image (to prevent changes to versions of pinned packages, and ensure the image is distributed with a known set of python packages Perhaps instead of using a venv for docker, we want to expose the |
|
Closing this out in favour of #8503 |
This PR changes behavior under docker, using the python virtual environment even in "production" mode.
The purpose for this is to ensure that any extra python packages that get installed (i.e. plugins) persist between container runs, and across the webserver and worker containers.
The Problem
Ref: #7709
The webserver and background worker processes run on separate container instances - meaning that they have different python package installation environments.
Thus, if a plugin is installed via the webserver (in the admin interface), it gets installed into the webserver container instance, but the background worker instance does not have a copy of the newly installed plugin code. When it tries to find it, it fails, and can result in some different subtle bugs (as well as the obvious "plugin does not work" issue).
As an added complication, if the background worker process is restarted, it may successfully result in the plugin being correctly installed inside that container, due to the auto-install behaviour of
plugins.txt- however, this is kinda flaky and the static files don't get copied across reliably in this scenario.The Solution
In the
init.shentrypoint script for both containers, active a python virtual environment which points to a subdirectory on the externally mounted volume. This means that:A) Installed plugin packages persist on the host machine (via mounted volume)
B) Installed plugin packages are shared between the webserver and background worker containers
Testing
You can test that this works on an existing docker installation by adding the following line to the
.envfile:Then, restart the docker containers.
Install a new plugin and verify that the plugin has been installed in the
<data>/venv/subdirectory in the mounted volumeBase Packages
Base python packages (that is, everything in
requirements.txtneeded for core InvenTree functionality) is installed inside the container image - when the container is built. Thus, only secondary packages (user installed plugins, etc) will persist in the external venv.