带有pip grpcio的Dockerfile的构建速度非常慢

时间:2018-10-20 10:25:58

标签: python docker pip dockerfile

我有一个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...

谢谢。

2 个答案:

答案 0 :(得分:6)

我遇到了同样的问题,并且通过升级pip解决了该问题:

$ pip3 install --upgrade pip

这是来自grpc项目维护者之一的话:

答案 1 :(得分:0)

有相同的问题,使用virtualenv和多阶段dockerfile对其进行了修复:

Events::whereHas('surgery.status', function ($query){
    $query->where('status_id', env('CONFIRMED'));
})->get();

这是我的要求。txt:

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