错误:在 Alpine Docker 映像上安装 PostGIS 时出现无法满足的约束 [英] ERROR: unsatisfiable constraints when installing PostGIS on the Alpine Docker image
问题描述
好的,所以任务看起来很简单!使用 Alpine
映像(因为它轻量级且安全)来执行一些 PostgreSQL
数据库创建/迁移.我正在使用以下 Dockerfile
使用代码 此处:
Ok, so the task seems pretty easy! Use an Alpine
image (as it is light-weight and secure) to perform some PostgreSQL
DB creation/migrations. I'm using the following Dockerfile
using the code here:
FROM alpine:latest
RUN apk add -U postgresql
# install PostGIS
ENV POSTGIS_VERSION 2.5.2
ENV POSTGIS_SHA256 225aeaece00a1a6a9af15526af81bef2af27f4c198de820af1367a792ee1d1a9
RUN set -ex
&& apk add --no-cache --virtual .fetch-deps
ca-certificates
openssl
tar
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/$POSTGIS_VERSION.tar.gz"
&& echo "$POSTGIS_SHA256 *postgis.tar.gz" | sha256sum -c -
&& mkdir -p /usr/src/postgis
&& tar
--extract
--file postgis.tar.gz
--directory /usr/src/postgis
--strip-components 1
&& rm postgis.tar.gz
&& apk add --no-cache --virtual .build-deps
autoconf
automake
g++
json-c-dev
libtool
libxml2-dev
make
perl
&& apk add --no-cache --virtual .build-deps-edge
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main
gdal-dev
geos-dev
proj4-dev
protobuf-c-dev
&& cd /usr/src/postgis
&& ./autogen.sh
# configure options taken from:
# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie
&& ./configure
# --with-gui
&& make
&& make install
&& apk add --no-cache --virtual .postgis-rundeps
json-c
&& apk add --no-cache --virtual .postgis-rundeps-edge
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main
geos
gdal
proj4
protobuf-c
&& cd /
&& rm -rf /usr/src/postgis
&& apk del .fetch-deps .build-deps .build-deps-edge
COPY ./db-creator.sh /db-creator.sh
CMD ["./db-creator.sh"]
然而,由于一些不可满足的约束
错误,依赖项没有使用apk
安装.错误如下,完整日志可在this issue我打开.
However, the dependencies are not installed using apk
due to some unsatisfiable constraints
error. The error is as follows and the full logs are available in this issue I opened.
ERROR: unsatisfiable constraints:
gdal-dev (missing):
required by: .build-deps-edge-20200123.143501[gdal-dev]
geos-dev (missing):
required by: .build-deps-edge-20200123.143501[geos-dev]
proj4-dev (missing):
required by: .build-deps-edge-20200123.143501[proj4-dev]
感谢任何帮助.
推荐答案
github 上的代码包含另一个图像 postgres:11-alpine 与问题中定义的图像进行比较:alpine:latest
.
The code on github contains another image postgres:11-alpine comparing to image defined in question: alpine:latest
.
包 gdal-dev、geos-dev, protobuf-c-dev 不再处于边缘回购测试分支,它们已迁移到稳定v3.11 存储库.proj4-dev
也被重命名为 proj-dev,它也在稳定的 v3.11 存储库中.
Packages gdal-dev, geos-dev, protobuf-c-dev are no longer in edge repo testing branch, they were migrated to stable v3.11 repository. Also proj4-dev
was renamed to proj-dev, which is also in stable v3.11 repository.
所以要修复Dockerfile
,我们只需要从 v3.11 repo 安装上述包,即更改这部分代码:
So to fix the Dockerfile
we just need to install above packages from v3.11 repo, ie change this part of code:
&& apk add --no-cache --virtual .build-deps
autoconf
automake
g++
json-c-dev
libtool
libxml2-dev
make
perl
&& apk add --no-cache --virtual .build-deps-edge
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main
gdal-dev
geos-dev
proj4-dev
protobuf-c-dev
proj4-dev
protobuf-c-dev
到这个:
&& apk add --no-cache --virtual .build-deps
autoconf
automake
g++
gdal-dev
geos-dev
json-c-dev
libtool
libxml2-dev
make
perl
proj-dev
protobuf-c-dev
最终的Dockerfile
是:
FROM alpine:3.11
RUN apk add -U postgresql
# install PostGIS
ENV POSTGIS_VERSION 2.5.2
ENV POSTGIS_SHA256 225aeaece00a1a6a9af15526af81bef2af27f4c198de820af1367a792ee1d1a9
RUN set -ex
&& apk add --no-cache --virtual .fetch-deps
ca-certificates
openssl
tar
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/$POSTGIS_VERSION.tar.gz"
&& echo "$POSTGIS_SHA256 *postgis.tar.gz" | sha256sum -c -
&& mkdir -p /usr/src/postgis
&& tar
--extract
--file postgis.tar.gz
--directory /usr/src/postgis
--strip-components 1
&& rm postgis.tar.gz
&& apk add --no-cache --virtual .build-deps
autoconf
automake
g++
gdal-dev
geos-dev
json-c-dev
libtool
libxml2-dev
make
perl
proj-dev
protobuf-c-dev
&& cd /usr/src/postgis
&& ./autogen.sh
# configure options taken from:
# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie
&& ./configure
# --with-gui
&& make
&& make install
&& apk add --no-cache --virtual .postgis-rundeps
json-c
&& apk add --no-cache --virtual .postgis-rundeps-edge
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main
geos
gdal
proj4
protobuf-c
&& cd /
&& rm -rf /usr/src/postgis
&& apk del .fetch-deps .build-deps .build-deps-edge
COPY ./db-creator.sh /db-creator.sh
CMD ["./db-creator.sh"]
这篇关于错误:在 Alpine Docker 映像上安装 PostGIS 时出现无法满足的约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!