I try to package my code in image using code below:
FROM torch_gpu:v1
WORKDIR /app
COPY ./code/* ./
CMD ["python","main.py"]
when I try to run it with docker run
. It goes wrong with
File "/app/main.py", line 30, in load_AU_model
from OpenGraphAU.conf import get_config, set_env, set_outdir, set_logger
ModuleNotFoundError: No module named 'OpenGraphAU'
The file dir tree is
/app
---/OpenGraphAU
----conf.py
---main.py
I don’t kown where is wrong and how to fix it?
but when I try run it with docker run --mount type=bind,source=./code,target=/app
, it work well.
I have added code to changed envirment var and it work well
os.chdir("/app")
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.insert(0, os.path.split(rootPath)[0])
sys.path.remove("/")
print(sys.path)
and ouput
['/app', '/opt/conda/lib/python311.zip', '/opt/conda/lib/python3.11', '/opt/conda/lib/python3.11/lib-dynload', '/opt/conda/lib/python3.11/site-packages', '/opt/conda/lib/python3.11/site-packages/setuptools/_vendor', '/tmp/tmpz4y0cvod']