postgresql - 错误 : unsatisfiable constraints when installing PostGIS on the Alpine Docker image

标签 postgresql docker postgis alpine

好的,所以任务看起来很简单!使用 Alpine图像(因为它重量轻且安全)来执行一些 PostgreSQL数据库创建/迁移。我正在使用以下 Dockerfile使用代码 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 安装依赖项由于一些 unsatisfiable constraints错误。报错如下,完整日志在this issue我打开了。
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 .

套餐 gdal-dev , geos-dev , protobuf-c-dev不再在边缘存储库测试分支中,它们已迁移到稳定的 v3.11 存储库。还有 proj4-dev更名为 proj-dev ,它也在稳定的 v3.11 存储库中。

所以要修复 Dockerfile我们只需要从 v3.11 repo 安装以上包,即更改这部分代码:

&& 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"]

关于postgresql - 错误 : unsatisfiable constraints when installing PostGIS on the Alpine Docker image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59882544/

相关文章:

ruby-on-rails - Rails + validates_overlap gem : When to add indexes to the database?

sql - postgres 返回的结果不正确

android - 是否有用于从 PostgreSQL 数据库呈现 OpenStreetMap 数据的 API?

sql - 如何在多行之间的 Postgresql 中查找重叠的日期范围?

ruby-on-rails - PG::UndefinedTable: 错误:关系 "events"不存在

ruby-on-rails - 从 pgAdmin III 运行 heroku 数据库命令? (哈利的预发射器)

docker - 如何在docker-compose服务中更新celery worker ,但保持长时间运行的任务处于事件状态,直到完成

python - 使用 docker exec_run python docker client 将文件传递到容器

python - 我在端口 8000 :80, 上的 apache+docker 上运行 django 应用程序需要用另一个端口运行另一个应用程序但不工作

postgresql - 如何在 ubuntu 14.04 中安装 postgis 1.5?