-
-
Notifications
You must be signed in to change notification settings - Fork 685
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
python module not found errors #546
Comments
@Divyesh3011 what version of slim are you using? Also wonder why you disabled http probing: Can you also describe what your app does and how the missing libraries are used in your app if you use them directly (e.g., pydantic)? |
slim version linux|Transformer|1.40.2|762eea87bafc4b04fe6b0642a62534a148acdaca|2023-05-20_06:09:23AM |
There's a couple of fastapi examples that might be useful for you: https://github.com/slimtoolkit/examples/tree/master/3rdparty/python_fastapi_official (and there's another one in the 3rdparty director, it has fastapi in its name too) I thought you disabled http probing because you didn't have any EXPOSE instructions in your Dockerfile. You should have it, but if you don't you should use the |
i tried updating my dockerfile according to your suggestion but getting this error i have added the slim-report file too dockerfile cmd=build info=container message='obtained IP address' ip='172.17.0.2' cmd=build prompt='waiting for the HTTP probe to finish'
|
Can you describe what your app does? |
the app is part of multiple microservices which are use to scan the image for any vulnerablity i Docker file one of the depedecy-error i am facing (this dependecy is mentioned in requirement.txt file) with normal image it work but with slim image i get errors |
@kcq It shows no app.models.discovery but i have checked the path it contains the file
|
Facing Modules / package error
2023-07-12 17:08:15 Traceback (most recent call last):
2023-07-12 17:08:15 File "/usr/local/lib/python3.8/decimal.py", line 3, in
2023-07-12 17:08:15 from _decimal import *
2023-07-12 17:08:15 ModuleNotFoundError: No module named 'numbers'
2023-07-12 17:08:15
2023-07-12 17:08:15 During handling of the above exception, another exception occurred:
2023-07-12 17:08:15
2023-07-12 17:08:15 Traceback (most recent call last):
2023-07-12 17:08:15 File "main.py", line 2, in
2023-07-12 17:08:15 from fastapi import FastAPI
2023-07-12 17:08:15 File "/usr/local/lib/python3.8/site-packages/fastapi/init.py", line 7, in
2023-07-12 17:08:15 from .applications import FastAPI as FastAPI
2023-07-12 17:08:15 File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", line 3, in
2023-07-12 17:08:15 from fastapi import routing
2023-07-12 17:08:15 File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 20, in
2023-07-12 17:08:15 from fastapi import params
2023-07-12 17:08:15 File "/usr/local/lib/python3.8/site-packages/fastapi/params.py", line 4, in
2023-07-12 17:08:15 from pydantic.fields import FieldInfo, Undefined
2023-07-12 17:08:15 File "pydantic/init.py", line 2, in init pydantic.init
2023-07-12 17:08:15 File "pydantic/dataclasses.py", line 3, in init pydantic.dataclasses
2023-07-12 17:08:15 import copy
2023-07-12 17:08:15 File "pydantic/class_validators.py", line 8, in init pydantic.class_validators
2023-07-12 17:08:15 File "pydantic/errors.py", line 1, in init pydantic.errors
2023-07-12 17:08:15 File "/usr/local/lib/python3.8/decimal.py", line 8, in
2023-07-12 17:08:15 from _pydecimal import *
2023-07-12 17:08:15 ModuleNotFoundError: No module named '_pydecimal'
Steps to Reproduce the Problem (DockerFile)
FROM python:3.8-slim-buster AS build
WORKDIR /app
COPY . .
RUN apt-get update && apt-get install -y --no-install-recommends
build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir -r requirements.txt
Stage 2: Final stage
FROM python:3.8-slim-buster
WORKDIR /app
COPY --from=build /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
COPY . .
RUN pip install --no-cache-dir -r requirements.txt fastapi==0.68.1 uvicorn==0.15.0
CMD ["bash", "azure-soc2-manager.sh"]
EXPOSE 8000
Create preserved-paths.txt file in the final image
RUN echo "/usr/local/usr/local/lib/python3.8" > /preserved-paths.txt
command use are
docker build -t soc2-test-1 . (to build-image)
docker-slim build --target soc2-test-11 --tag soc2-test-slim --http-probe=false
docker images | grep soc2
soc2-test-1 slim
cf086482e0b3 About a minute ago 33.9MB
soc2-test-1 latest
d3fdfab4467d 10 minutes ago 279MB
The text was updated successfully, but these errors were encountered: