错误:在Alpine Docker映像上安装PostGIS时无法满足的约束条件

问题描述 投票:2回答:1

好,所以任务似乎很简单!使用Alpine图像(重量轻且安全)来执行某些PostgreSQL DB创建/迁移。我正在使用代码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]

感谢您的任何帮助。

postgresql docker postgis alpine
1个回答
0
投票

问题中的代码已过时,实际上,定义FROM alpine:latest图像不是一个好习惯,因为情况一直在变化,并且一段时间后alpine:latest完全是另一幅图像。因此,正是在释放alpine:3.11时才发生的。

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"]
© www.soinside.com 2019 - 2024. All rights reserved.