slimtoolkit / slimtoolkit/slim

slim fails loading python modules in build

Open
#490 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.