Docker pip安装创建递归的tmp/pipbuild/tmp/pipbuild。。。折叠

2024-10-01 19:17:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我对Docker和Python应用程序有点陌生。我遇到了一个非常复杂的问题,按了一下按钮,我奇迹般地解决了这个问题。但是,我既不了解问题,也不了解解决方案,我想两者都了解。你知道吗

因此,我的应用程序根目录中有一个Dockerfile,它可以执行以下操作:

COPY . .
RUN apt-get update && apt-get install -y enchant \
  && pip install --extra-index-url=${ARTIFACTORY} --no-cache-dir requirements.txt \
  && pip install . \ # installs my python app using setup.py
  && python -m app.run_model
ENTRYPOINT ...

由于磁盘空间不足,此操作始终失败。好吧,好吧,我删除了旧的,未使用的图像。但我不认为这是问题所在,因为它一直在失败,而且还生成了这些超长、超奇怪的递归文件名,比如:

/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/tmp/pip-fih7z5-build/...

在Docker命令周围添加以下包装器以某种方式起作用:

COPY . /workdir
RUN cd /workdir \
...
  && rm -rf /workdir

为了通过安装阶段(尽管现在看起来应用程序进程仍在失败),我不确定发生了什么。有人有什么见解吗?我最好的猜测是这两个pip install不知何故制造了某种递归的噩梦?你知道吗

我的setup.py相当标准,我认为:

#!/usr/bin/env python
from glob import glob
from os.path import abspath, basename, dirname, join, splitext
from setuptools import find_packages, setup

here = abspath(dirname(__file__))

with open(join(here, 'README.md')) as f:
    long_description = f.read()

setup(
    ...
    packages=find_packages('src'),
    package_dir={'': 'src'},
    py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
    zip_safe=False,
    include_package_data=True,
    install_requires=[
    'scikit-learn==0.18.1',
    'scipy==0.19.1',
    'nltk==3.2.3',
    'requests==2.17.3',
    'jsonschema==2.6.0',
    'pandas==0.20.1',
    'numpy==1.13.0',
    'textblob==0.12.0',
    'textstat==0.3.1',
    'langdetect==1.0.7',
    'unidecode==0.4.20',
    'Flask==0.12.1',
    'Flask-Env==1.0.1',
    'pyenchant==1.6.11'
    ],
    setup_requires=[
        'flake8==3.3.0',
    ],
    tests_require=[],
)

````


Tags: installpippathfrompyimportbuildsrc

热门问题