【问题标题】:App Engine Flexible Environment - Dockerfile installing outdated version of GDALApp Engine 灵活环境 - 安装过时版本的 GDAL 的 Dockerfile
【发布时间】:2020-04-23 14:56:13
【问题描述】:

我正在尝试在 Google App Engine 柔性环境中使用 Docker 映像。

FROM ubuntu:bionic
MAINTAINER Makina Corpus "contact@makina-corpus.com"

ENV PYTHONUNBUFFERED 1
ENV DEBIAN_FRONTEND noninteractive
ENV LANG C.UTF-8

RUN apt-get update -qq && apt-get install -y -qq \
    # std libs
    git less nano curl \
    ca-certificates \
    wget build-essential\
    # python basic libs
    python3.8 python3.8-dev python3.8-venv gettext \
    # geodjango
    gdal-bin binutils libproj-dev libgdal-dev \
    # postgresql
    libpq-dev postgresql-client && \
    apt-get clean all && rm -rf /var/apt/lists/* && rm -rf /var/cache/apt/*

# install pip
RUN wget https://bootstrap.pypa.io/get-pip.py && python3.8 get-pip.py && rm get-pip.py
RUN pip3 install --no-cache-dir setuptools wheel -U

CMD ["/bin/bash"]

docker 镜像似乎可以正确构建,但是当服务部署应用程序崩溃时,我收到以下错误消息:

  File "/Users/NAME/Documents/gcp/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 183, in IsDone
    encoding.MessageToPyValue(operation.error)))
OperationError: Error Response: [9] 
Application startup error! Code: APP_CONTAINER_CRASHED

ERROR: (gcloud.app.deploy) Error Response: [9] 
Application startup error! Code: APP_CONTAINER_CRASHED

这是失败的,因为 Dockerfile 正在安装一个明显过时的 GDAL 包版本,它与最新的 python 安装冲突。

如何确保 dockerfile 具有正确的软件包存储库并安装正确的最新版本?在开始安装之前,我可以插入一些行来更新存储库,或者至少打印存储库吗?

编辑:

我的 app.yaml:

# [START django_app]

runtime: custom
env: flex
entrypoint: gunicorn -b :$PORT MyApplication.wsgi

runtime_config:
  python_version: 3
# [END runtime]

handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
#- url: /static
#  static_dir: static/
#- url: /MyApplication/static
#  static_dir: MyApplication/static/


# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
  script: auto
# [END django_app]

resources:
  cpu: 1
  memory_gb: 2
  disk_size_gb: 10

【问题讨论】:

    标签: docker ubuntu google-app-engine dockerfile gdal


    【解决方案1】:

    您的 App Engine 部署失败,因为它 needs a service listening on port 8080 并且无法在云上运行 bash。如果您需要调试您的 App Engine Flex 实例,您需要首先在端口 8080 and then enable SSH 上获取服务。

    【讨论】:

    • 如果您使用 python 为您的流量提供服务,最好使用 Google 图片github.com/GoogleCloudPlatform/python-runtime
    • 谢谢!如何确保我的 Django 应用程序在 8080 上运行?这是在 app.yaml 中完成的(我已经编辑了问题以显示我的文件)?肯定宁愿使用谷歌图像(我只需要确保安装了这些软件包:gdal-bin binutils libproj-dev libgdal-dev)。我应该将“FROM ubuntu:bionic”替换为“来自 gcr.io/google-appengine/python”吗?
    • 鉴于您将使用 Django,我的工作将基于 Kubernetes section 中的 docker 文件并合并来自 this tutorial 的 django 部分
    【解决方案2】:

    herehere 正在解决类似的问题

    您的 Dockerfile 应该运行一个命令来启动您在端口 8080 上侦听的应用程序:

    CMD gunicorn -b :$PORT MyApplication.wsgi
    

    GAE 实际上使用docker run 启动容器,我不确定为什么它们还会在app.yaml 文件中指定entrypoint。 GAE 最好不要问太多问题。

    上面一些 cmets 中提到的其他需要您考虑的问题:

    • 使用 Google 的 GAE 基础镜像会不会更好(如上面一些 cmets 中提到的)-> FROM gcr.io/google-appengine/python
    • 如果是这样,您需要考虑它基于 Ubuntu 16.04,并且您需要更新依赖项(通过添加 UbuntuGIS PPA:add-apt-repository -y ppa:ubuntugis/ppa
    • 如何安装其他依赖项?使用需求文件运行pip

    【讨论】:

      猜你喜欢
      • 2020-08-25
      • 2020-11-23
      • 2017-11-16
      • 2016-08-26
      • 1970-01-01
      • 1970-01-01
      • 2018-11-02
      • 2015-11-11
      • 2021-10-11
      相关资源
      最近更新 更多