我想将GeoDjango(需要的部门:GDAL,GEOS,PROJ.4)添加到我的docker alpine镜像中。我的Dockerfile已经有一个requirements.txt文件设置。
我抬起头来,例如在PyPi上使用GDAL,并发现了GDAL的四个依赖项:
“ libgdal(3.0.1或更高版本)和头文件(gdal-devel) numpy(1.0.0或更高版本)和头文件(numpy-devel)(没有明确要求,但是如果没有它,许多示例和实用程序将无法使用)“
所以我认为我需要添加:numpy,numpy-devel,libgdal和gdal-devel?
我将这些依赖项添加到我的requirements.txt文件中,但是我收到消息,要求numpy继续进行GDAL。
所以我直接将numpy添加到我的dockerfile中
Dockerfile ...
COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache postgresql-client jpeg-dev
RUN apk add --update --no-cache --virtual .tmp-build-deps \
gcc libc-dev linux-headers postgresql-dev musl-dev zlib-dev
RUN pip install numpy==1.14.3 libgdal==3.0.1
RUN pip install -r /requirements.txt
RUN apk del .tmp-build-deps
...
requirements.txt ...
GDAL>=3.0.1,<3.1.0
...
当我尝试构建docker镜像“ docker-compose build”时,这是错误: ...
Step 7/18 : RUN pip install numpy==1.14.3 libgdal==3.0.1
---> Running in ffaa7d1b9ad6
Collecting numpy==1.14.3
Downloading https://files.pythonhosted.org/packages/b0/2b/497c2bb7c660b2606d4a96e2035e92554429e139c6c71cdff67af66b58d2/numpy-1.14.3.zip (4.9MB)
Collecting libgdal==3.0.1
ERROR: Could not find a version that satisfies the requirement libgdal==3.0.1 (from versions: none)
ERROR: No matching distribution found for libgdal==3.0.1
WARNING: You are using pip version 19.1.1, however version 19.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ERROR: Service 'app' failed to build: The command '/bin/sh -c pip install numpy==1.14.3 libgdal==3.0.1' returned a non-zero code: 1