App Engine灵活环境 - Docker文件包安装在镜像构建时被跳过。

问题描述 投票:2回答:1

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

RUN add-apt-repository ppa:ubuntugis/ppa

RUN sudo apt-get install -y gdal-bin

终端显示gcloud应用部署命令从拉动python运行时开始,然后跳过处理Dockerfile,直到这一行。

RUN virtualenv /env -p python3.7

这是我的整个Dockerfile 当App尝试启动时,由于找不到我尝试安装的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
docker google-app-engine google-cloud-platform app-engine-flexible
1个回答
1
投票

按照你的 Dockerfile云构建不应该拉动Python运行时,而应该拉动Python运行时。ubuntu:bionic 图像。当您部署非定制的 Flex 应用程序时,Cloud Build 将提取 Python 运行时。

我相信您需要在您的 app.yaml 文件中设置适当的运行时,就像这样。

runtime: custom
env: flex
...

而不是 runtime:python.

另外,在尝试使用你的 Dockerfile 为了测试,我注意到一些问题。

  • 它似乎 add-apt-repository 默认情况下是不可用的。ubuntu:bionic 镜像,我不得不手动安装。
  • 你不能在Dockerfile中运行sudo。

所以你的Docker文件会是这样的。

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
...
© www.soinside.com 2019 - 2024. All rights reserved.