gpt4 book ai didi

docker - App Engine灵活环境-镜像构建时跳过Dockerfile软件包安装

转载 作者:行者123 更新时间:2023-12-02 18:26:33 26 4
gpt4 key购买 nike

在App Engine灵活环境中构建自定义运行时时,我试图安装软件包的Dockerfile中的行似乎被跳过了。特别是这两个:

RUN add-apt-repository ppa:ubuntugis/ppa

RUN sudo apt-get install -y gdal-bin

终端显示gcloud app deploy命令通过拉动python运行时开始,然后跳过处理Dockerfile直到此行:
RUN virtualenv /env -p python3.7

这是我的整个Dockerfile。当应用程序尝试启动时,它失败了,因为它找不到我尝试安装的GDAL软件包安装。
FROM ubuntu:bionic


RUN add-apt-repository ppa:ubuntugis/ppa

RUN sudo apt-get install -y gdal-bin


# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
# Use -p python3 or -p python3.7 to select python version. Default is version 2.
RUN virtualenv /env -p python3.7



# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
RUN pip install -r requirements.txt

# Add the application source code.
ADD . /


# Run a WSGI server to serve the application. gunicorn must be declared as
# a dependency in requirements.txt.
CMD gunicorn -b :$PORT main:app

最佳答案

根据您的Dockerfile,Cloud Build不应拉Python运行时,而应拉ubuntu:bionic图像。部署非自定义Flex应用程序时,Cloud Build将拉动Python运行时。

我相信您需要在app.yaml文件中设置适当的运行时,如下所示:

runtime: custom
env: flex
...

而不是 runtime:python

另外,在尝试使用 Dockerfile进行测试后,我注意到了两个问题:
  • 似乎add-apt-repository图像上默认不提供ubuntu:bionic,我必须手动安装它。
  • 您无法在Dockerfile中运行sudo

  • 因此,您的Dockerfile如下所示:
    FROM ubuntu:bionic

    RUN apt-get update && apt-get install software-properties-common -y
    RUN add-apt-repository ppa:ubuntugis/ppa

    RUN apt-get install -y gdal-bin
    ...

    关于docker - App Engine灵活环境-镜像构建时跳过Dockerfile软件包安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61712215/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com