-
-
Notifications
You must be signed in to change notification settings - Fork 845
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
[FR] Add a debian-based docker image so inventree-server can connect to USB devices directly #7389
Comments
Alpine was chosen for the smaller and faster to build image, I do not think it makes sense to switch for a single use case. |
Would you please either direct me to the documentation concerning using that baseimage environment variable, or write up a brief set of instructions on how to use it? That environment variable is not present nor described in the .env file that comes with this project, and it is not described in anything docker related either. |
There are potentially some other reasons to use a debian based docker image: Playwright TestingNow that we are moving to front-end testing with playwright it would be good to be able to run these tests in the default devcontainer setup. However with the current alpine image this is not possible due to incompatibility Build TimesOur docker build times (on some architectures) are very long right now due to some library issues with alpine. A debian image should reduce this significantly: Match InstallerOur "installer" targets debian based distributions - it would be great to have a single set (or at least a reduced common set) of required packages. This is something I've been considering for a while but have had no time to investigate. If we were to move we would need to have a debian based image which does not blow out our build times or image sizes.
You should just be able to follow the |
For posterity: the migration to the debian image was not trivial due in a large part to the different system package managers and different package names. The initial setup with invoke is now rather unstable and performs better when you run the commands from a shell within the modified invented-server docker container. USB functionality is working, and I will circle back here in a couple hours to couple days to post the modified dockerfile and docker-compose.yml in case anyone wants to follow in my footsteps and do a better job. Note that I am a major GitHub noob, so it would probably be best if somebody else makes a PR or whatever out of what I put here. Perhaps we can chuck it all into a giant if statement in the dockerfile and build to Debian or alpine based on an environment variable? |
I would not support this - crafting the docker image is a very delicate operation. If we do want to move to a debian image, I would prefer to only support that. |
The build time is mainly caused by 1 single package building 2-3h. I tried building and referencing it twice now and failed. Before we touch anything regarding the image I would like to hear the opinion of @wolflu05, he has proven to be very provicient in this area |
Seems like only the new Where I initially refactored to docker image to use alpine instead of debian this was not part of inventree and therefore the build time was only slightly higher, but totally fine for that huge reduction of the image size. See #5007 (comment) Regarding the change, I do not really care, but we should keep the image size in mind. Having an image that is again > 1GB would not be optimal. Also switching would mean, users need to update their automatic deployment (e.g. when using custom system packages like the cups headers). |
Just read that blog post from GitHub. Will also be interesting to speed up things in general for ARM, when GitHub releases this to open source projects by the end of this year like they stated. https://github.blog/2024-06-03-arm64-on-github-actions-powering-faster-more-efficient-build-systems/ |
I wanted to circle back to this and provide the working dockerfile and docker-compose.yml to build a debian-based usb-capable inventree-server image. I'm fairly certain I broke the dev server, since I was just bug whack-a-mole-ing and I had to import the source code in that image for some reason. As I said before, I'm a total git noob and I'd prefer somebody else takes this the rest of the way. Dockerfile:
docker-compose.yml:
I haven't changed much, but it took a long-ass time to get there. This definitely builds on an 8gb raspberry pi 4 running the current Pi OS. Make sure you also have at least 8gb free on the filesystem to build-- Again, I'm a noob and I doubt what I did was the most efficient. Plz improve. Additionally, if you want to use this for my purposes-- printing labels-- remember to downgrade the Inventree venv's version of PIL to 9.5.0, unless you figure out a way to add that into the dockerfile. Best of luck, I have no idea what I'm doing. I'll link to the issue wherein I provide code to run Brother QL-570s and QL-600s via USB directly from the container momentarily. All that said, having had to write a printer driver on top of all of this anyway, I'm beginning to wonder if the smart solution is to leave the inventree-server image alone and create a separate image altogether that builds from debian and provides USB printing plugins. We could also provide that end of the socket as a cups-style daemon to run directly on the host system. Basically what I'm saying is I'd like to follow the progress of development but I'm tired of waiting 2 hours for inventree-server to compile, so for now I've got what I've got. |
@wolflu05 we need this for tracing support - it would be hard to work around this and still support the feature |
That's what I was thinking a while ago too for my cups plugin, but I don't have that spare time to implement this right now. I thought about building a custom image for my cups plugin that just exposes the required native apis via a REST or socket interface which then runs in a second container where the printing driver running on the inventree worker communicates with via an internal network. |
This issue seems stale. Please react to show this is still important. |
Please verify that this feature request has NOT been suggested before.
Problem statement
The Alpine Linux version of the python docker image that Inventree-Server is based on is incompatible with libusb-- See the issue that I have lodged on that project here. Because of this, there is pretty much no way to get anything in the inventree-server image to connect directly to USB devices.
Suggested solution
I have found that the debian version of the python docker image is fully compatible with libusb, and better yet, brother_ql.py works perfectly on it. In my use case, if the inventree-server were moved to that image, I would be able to plug my Brother QL-600 (an exceedingly cheap label printer) directly into my pi-hosted inventree instance. Unfortunately, the existing bare metal installation instructions don't seem to piece out how to reconstruct the inventree-server instance alone.
Describe alternatives you've considered
We could also wait for libusb to address the issue their package has in Alpine Linux containers. We could also create an entirely separate container that deals with USB devices, and connect it to inventree-server over IP. Think a CUPS server-style implementation. Unfortunately I have yet to find a package that we could plug into an Alpine Linux container that will fix this.
Examples of other systems
brother_ql_web can be containerized with the following dockerfile and compose.yml on the official debian based python image and will print to my QL-600 perfectly fine.
Dockerfile:
compose.yml:
Place these into the folder that contains brother_ql_web.py and the rest of that project's assets, then alter the config.example.json to read as follows:
build with:
docker compose up -d --force-recreate --build
connect to the container's IP on port 8013 and voi-la, you can print directly from the container over USB without issue.
Do you want to develop this?
The text was updated successfully, but these errors were encountered: