【问题标题】:ERROR: unsatisfiable constraints when installing PostGIS on the Alpine Docker image错误:在 Alpine Docker 映像上安装 PostGIS 时出现无法满足的约束
【发布时间】:2020-01-23 15:58:08
【问题描述】:

好的,所以任务看起来很简单!使用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"]

但是,由于某些unsatisfiable constraints 错误,未使用apk 安装依赖项。错误如下,我打开的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]

感谢任何帮助。

【问题讨论】:

    标签: postgresql docker postgis alpine


    【解决方案1】:

    github 上的代码包含另一个图像 postgres:11-alpine,与有问题的图像相比:alpine:latest

    gdal-devgeos-devprotobuf-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"]
    

    【讨论】:

    • 感谢您的帮助。配置时出错:+ apk add --no-cache --virtual .build-deps-edge --repository dl-cdn.alpinelinux.org/alpine/edge/testing --repository dl-cdn.alpinelinux.org/alpine/edge/main gdal-dev geos-dev proj4-dev protobuf-c-dev错误:不可满足的约束:gdal-dev(缺少):要求:.build-deps-edge-20200124.075938[gdal-dev] geos-dev(缺少):要求:.build-deps-edge-20200124.075938[geos-dev ] proj4-dev(缺少):要求:.build-deps-edge-20200124.075938[proj4-dev]
    • 非常感谢@Nickolay 的精心帮助!值得一提的是,./configure 命令失败,因为上面的 Dockerfile 没有pg_config。除了运行启动 Postgres 服务器(例如,通过设置一些 ENV)之外,还有什么建议吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-09
    相关资源
    最近更新 更多