首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当使用lib时,Docker映像python-高寒失败。

当使用lib时,Docker映像python-高寒失败。
EN

Stack Overflow用户
提问于 2019-11-13 14:46:35
回答 2查看 1.6K关注 0票数 0

我有以下Dockerfile:

代码语言:javascript
运行
复制
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 (我将所有内容都放在入口点,因为我使用的是网络中的代理问题-不要怪我,这是我找到解决问题的唯一方法):

代码语言:javascript
运行
复制
#!/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

但是,当我试图运行容器时,我会得到以下错误:

代码语言:javascript
运行
复制
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时,这个错误不会发生。我做错了什么?谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-05-05 22:44:46

当遇到此错误时,此配置对我有效。

代码语言:javascript
运行
复制
    # For more information, please refer to https://aka.ms/vscode-docker-python
    FROM python:3-alpine3.10
    
    RUN apk add build-base

    RUN pip install --upgrade pip

    # Copy the requirements.txt to the root of the docker image
    COPY ./requirements.txt .
    
    # Keeps Python from generating .pyc files in the container
    ENV PYTHONDONTWRITEBYTECODE=1

    # Turns off buffering for easier container logging
    ENV PYTHONUNBUFFERED=1

    ENV TZ=$TIME_ZONE

    ENV DJANGO_PROJECT_NAME core

    ENV EXPOSED_CONTAINER_PORT 2092
    
    # Add header files required to install dependencies in the requirements.txt file
    RUN apk add --update --no-cache --virtual .tmp gcc libc-dev linux-headers python3-dev musl-dev unixodbc unixodbc-dev \
        && apk add --no-cache mariadb-dev mariadb-client postgresql-libs postgresql-dev \
          && apk add jpeg-dev zlib-dev libjpeg

    # Install pip requirements
    RUN pip install -r requirements.txt

    # Install Pillow for image management
    RUN pip install Pillow

    # Install MS-SQL dependencies
    RUN pip install mssql-django

    # Install postgres engine adapter
    RUN pip install psycopg2

    # Install pytest for running unit-tests
    RUN pip install pytest

    # Delete the temporarily directory used for downloading the required image header.
    # This is done to reduce on the image size and also to remove these redundant files
    RUN apk del .tmp

    # This is where static files will be stored in the container. -p makes is used to create all directories that don't exist
    RUN mkdir -p /app/static

    # Change directory and make app as the current working directory
    WORKDIR /app

    COPY . /app

    CMD find .

    RUN pytest /app/tests/
    
    # Creates a non-root user with an explicit UID and adds permission to access the /app folder
   
    # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
    
    RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
    
    USER appuser
    

    # Expose the container's point in order to be accessed outside the container
    EXPOSE $EXPOSED_CONTAINER_PORT:$EXPOSED_CONTAINER_PORT
    
    # Copy the entry point script to the container root directory
    COPY ./entrypoint.sh /

    ENTRYPOINT ["sh", "/entrypoint.sh" ]
票数 1
EN

Stack Overflow用户

发布于 2022-06-20 18:28:12

高山平台不支持SAP NWRFC SDK,高山上不支持基于RFC SDK的连接器。与节点-rfc:https://github.com/SAP/node-rfc/issues/148的问题相同。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58839630

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档