在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如下所示:
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/