slimtoolkit / slimtoolkit/slim
slim fails loading python modules in build
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.4k
- Forks
- 840
- PR merge metrics
- No merged PRs in 30d
Description
I was trying to slim an image that works perfectly , but when running this command :
slim build --target mailserver:latest --tag mailserver:slim --exec "python3 mailserver.py" --expose 2025 -http-probe=false --preserve-path /home/pmail/.local/lib/python3.9/site-packages it seems fails to load the library I installed with pip3 in requirements :
slim[build][exec]: output: Traceback (most recent call last):
slim[build][exec]: output: File "/home/pmail/mailserver.py", line 4, in <module>
slim[build][exec]: output: from aiosmtpd.controller import Controller
slim[build][exec]: output: ModuleNotFoundError: No module named 'aiosmtpd'
however if I run the image import is ok :
gcasale@deb-hp-8300:~$ docker attach a40d0f417e0f
pmail@a40d0f417e0f:~$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from aiosmtpd.controller import Controller
>>>
how can I solve this issue ?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the shown slim build command with mailserver.py and the preserved site-packages path, then inspect the build entry point handling module discovery and --preserve-path. Done means the slimmed image can run mailserver.py and import aiosmtpd from the pip-installed requirements without changing the original image behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100