docker - App Engine Flexible - Docker 文件无法安装 GDAL

标签 docker google-app-engine dockerfile gdal

我正在尝试将 Django 应用程序部署到 App Engine 柔性环境。我的 dockerfile 无法安装 GDAL。

这是我在运行 gcloud app deploy 时收到的错误消息:

  File "/env/lib/python3.7/site-packages/django/contrib/gis/gdal/libgdal.py", line 42, in <module>
    % '", "'.join(lib_names)
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
[2020-04-24 16:12:26 +0000] [8] [INFO] Worker exiting (pid: 8)
[2020-04-24 16:12:26 +0000] [1] [INFO] Shutting down: Master
[2020-04-24 16:12:26 +0000] [1] [INFO] Reason: Worker failed to boot.

这是我的 dockerfile:

FROM ubuntu:bionic

RUN apt-get update && apt-get install -y \
  binutils \
  gdal-bin \
  python3-gdal \
  ibgdal-dev \
  libproj-dev

# 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

这是我的 app.yaml:

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  # You can also specify 2 for Python 2.7
  python_version: 3.7

我知道我在问一个非常相似的问题,并且正在回答 here ,但提问者自己的解决方案似乎没有用。

最佳答案

对我来说,您似乎缺少正确的 gdal 安装。事实上,安装它可能有点棘手,但在 ubuntu(也有 docker)上,我通常有很好的安装经验 ubuntugis .

这是一个例子:

FROM ubuntu:bionic

RUN apt-get update && apt-get install -y \
    software-properties-common \
    python3 \
    python3-dev \
    python3-pip \
  && rm -rf /var/lib/apt/lists/*

RUN add-apt-repository ppa:ubuntugis/ppa

RUN apt-get update && apt-get install -y \
    gdal-bin=2.4.2+dfsg-1~bionic0 \
    python3-gdal \
  && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y libpq-dev \
  && rm -rf /var/lib/apt/lists/*
...

关于docker - App Engine Flexible - Docker 文件无法安装 GDAL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61412885/

相关文章:

centos - 如何从中恢复

php - 未找到带有App Engine标准类 'Facade\Ignition\IgnitionServiceProvider'的Laravel

docker - Dockerfile 中的开发依赖项或用于生产和测试的单独 Dockerfile

java - JPA 多对多关系与额外的枚举列

python - 使用 Python apiclient 忙于调用 Google Calendar API v3 时出现 TypeError

linux - dockerfile 中的 RUN 命令产生的结果与在容器中手动运行相同命令产生的结果不同

docker - 无法从 Dockerfile 运行源命令

windows - 重启docker后docker compose无法启动service network not found

java - 混合基础镜像的 Docker 镜像

api - nginx proxy_pass for get request api call with parameters