我有以下 Dockerfile:
FROM python:3.7-alpine
WORKDIR /msa-app/
EXPOSE 3000
ENV LD_LIBRARY_PATH="/usr/local/lib"
ENV LD_RUN_PATH="/usr/local/lib"
ENV SAPNWRFC_HOME="/usr/local/sap/nwrfcsdk"
ENV PATH="${PATH}:/usr/sap/nwrfcsdk/lib"
COPY nwrfcsdk/nwrfcsdk /usr/local/sap/nwrfcsdk
COPY nwrfcsdk/nwrfcsdk.conf /etc/ld.so.conf.d/nwrfcsdk.conf
COPY msa-app /msa-app/
RUN chmod +x /msa-app/entrypoint.sh
ENTRYPOINT /msa-app/entrypoint.sh
使用以下 entrypoint.sh (由于我正在使用的网络中的代理问题,我将所有内容都放在了入口点 - 不要怪我,这是我发现解决问题的唯一方法):
#!/bin/sh
#Creates and activates virtual env
echo "*** Activating Python virtual environment"
python -m venv /msa-app/venv && source /msa-app/venv/bin/activate
echo "*** Installing pip requirements"
pip install --upgrade pip && pip install -r /msa-app/requirements.txt
echo "*** Installing pyrfc"
pip install /msa-app/pyrfc-1.9.95-cp37-cp37m-linux_x86_64.whl
echo "*** Configuring SAPNWRFC PyRFC"
ln -s /usr/bin/python3 python
mkdir -p /etc/ld.so.conf.d/
mkdir -p /usr/sap/
ldconfig /usr/local/lib
#Starts gunicorn for flask
echo "*** Starting application"
cd /msa-app && gunicorn -w 2 -b 0.0.0.0:3000 run:app
但是当我尝试运行容器时,出现以下错误:
ImportError: Error loading shared library libsapnwrfc.so: No such file or directory (needed by /msa-app/venv/lib/python3.7/site-packages/pyrfc/_pyrfc.cpython-37m-x86_64-linux-gnu.so)
但是,当我使用普通的非高山 Python Docker 映像时,不会发生此错误。我究竟做错了什么?谢谢你。