Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 通过pip安装grpcio时Docker构建耗时过长_Python_Docker_Pip_Dockerfile_Grpc - Fatal编程技术网

Python 通过pip安装grpcio时Docker构建耗时过长

Python 通过pip安装grpcio时Docker构建耗时过长,python,docker,pip,dockerfile,grpc,Python,Docker,Pip,Dockerfile,Grpc,我有一个Dockerfile,它通过pip安装了一些软件包。 其中一些需要grpcio,构建此部件只需几分钟 有没有人有加快这部分速度的建议 Installing collected packages: python-dateutil, azure-common, azure-nspkg, azure-storage, jmespath, docutils, botocore, s3transfer, boto3, smmap2, gitdb2, GitPython, grpcio, proto

我有一个Dockerfile,它通过pip安装了一些软件包。 其中一些需要
grpcio
,构建此部件只需几分钟

有没有人有加快这部分速度的建议

Installing collected packages: python-dateutil, azure-common, azure-nspkg, azure-storage, jmespath, docutils, botocore, s3transfer, boto3, smmap2, gitdb2, GitPython, grpcio, protobuf, googleapis-common-protos, grpc-google-iam-v1, pytz, google-api-core, google-cloud-pubsub
Found existing installation: python-dateutil 2.7.3
  Uninstalling python-dateutil-2.7.3:
    Successfully uninstalled python-dateutil-2.7.3
Running setup.py install for grpcio: started
Running setup.py install for grpcio: still running...
Running setup.py install for grpcio: still running...
Running setup.py install for grpcio: still running...

谢谢。

也有同样的问题,通过使用virtualenv和多级dockerfile修复了它:

FROM python:3.7-slim as base

# ---- compile image -----------------------------------------------
FROM base AS compile-image
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
  build-essential \
  gcc

RUN python -m venv /app/env
ENV PATH="/app/env/bin:$PATH"

COPY requirements.txt .
RUN pip install --upgrade pip
# pip install is fast here (while slow without the venv) :
RUN pip install -r requirements.txt

# ---- build image -----------------------------------------------
FROM base AS build-image
COPY --from=compile-image /app/env /app/env

# Make sure we use the virtualenv:
ENV PATH="/app/env/bin:$PATH"
COPY . /app
WORKDIR /app

以下是我的requirements.txt:

fastapi==0.27.*
grpcio-tools==1.21.*
uvicorn==0.7.*

我也遇到了同样的问题,通过升级pip解决了这个问题:

$ pip3 install --upgrade pip
以下是grpc项目的一位维护人员的一句话:


您使用的是什么docker图像,
alpine
?另外,图像中的目标Python版本是什么?请使用缓存,您不需要每次都构建这些层,在Dockerfile的末尾添加新的内容为grpcio构建轮子时遇到同样的问题,请参见此处代码:@ohduran您的链接已死亡您是对的@夸张,新链接:我很好奇为什么virtualenv会在这里有所作为。你让我开心!谢谢兄弟。事实上,升级pip对于解决此问题至关重要。不知道grpcio和Docker可能出了什么问题。仍然没有用于grpcio的aarch64(armv8)控制盘,因此这在大多数较新的arm处理器上不起作用