kopia lustrzana https://github.com/kartoza/docker-postgis
81 wiersze
2.9 KiB
Docker
81 wiersze
2.9 KiB
Docker
#--------- Generic stuff all our Dockerfiles should start with so we get caching ------------
|
|
ARG DISTRO=debian
|
|
ARG IMAGE_VERSION=buster
|
|
ARG IMAGE_VARIANT=-slim
|
|
FROM $DISTRO:$IMAGE_VERSION$IMAGE_VARIANT
|
|
MAINTAINER Tim Sutton<tim@kartoza.com>
|
|
|
|
# Reset ARG for version
|
|
ARG IMAGE_VERSION
|
|
|
|
RUN set -eux \
|
|
&& export DEBIAN_FRONTEND=noninteractive \
|
|
&& apt-get update \
|
|
&& apt-get -y --no-install-recommends install \
|
|
locales gnupg2 wget ca-certificates rpl pwgen software-properties-common gdal-bin iputils-ping \
|
|
&& sh -c "echo \"deb http://apt.postgresql.org/pub/repos/apt/ ${IMAGE_VERSION}-pgdg main\" > /etc/apt/sources.list.d/pgdg.list" \
|
|
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc -O- | apt-key add - \
|
|
&& apt-get -y --purge autoremove \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& dpkg-divert --local --rename --add /sbin/initctl
|
|
|
|
# Generating locales takes a long time. Utilize caching by runnig it by itself
|
|
# early in the build process.
|
|
COPY scripts/locale.gen /etc/locale.gen
|
|
RUN set -eux \
|
|
&& /usr/sbin/locale-gen
|
|
|
|
ENV LANG=en_US.UTF-8 \
|
|
LANGUAGE=en_US:en \
|
|
LC_ALL=en_US.UTF-8
|
|
RUN update-locale ${LANG}
|
|
|
|
#-------------Application Specific Stuff ----------------------------------------------------
|
|
|
|
# We add postgis as well to prevent build errors (that we dont see on local builds)
|
|
# on docker hub e.g.
|
|
# The following packages have unmet dependencies:
|
|
RUN set -eux \
|
|
&& export DEBIAN_FRONTEND=noninteractive \
|
|
&& apt-get update \
|
|
&& apt-get -y install postgresql-11 \
|
|
&& apt-get -y install netcat postgresql-11-postgis-2.5 postgresql-common \
|
|
&& apt-get -y install postgresql-11-pgrouting postgresql-11-ogr-fdw \
|
|
postgresql-plpython3-11 postgresql-11-cron python3-pip libpq-dev
|
|
|
|
RUN apt-get remove -y postgresql-11-postgis-3 postgresql-11-postgis-3-scripts || true; \
|
|
dpkg-query -W -f='${Status}' postgresql-11-postgis-2.5 | grep -xq 'install ok installed' && \
|
|
dpkg-query -W -f='${Status}' postgresql-11-postgis-2.5-scripts | grep -xq 'install ok installed'
|
|
RUN pip3 install psycopg2
|
|
|
|
# Compile pointcloud extension
|
|
RUN apt-get -y update; apt-get -y install build-essential autoconf postgresql-server-dev-11 libxml2-dev zlib1g-dev
|
|
|
|
RUN wget -O- https://github.com/pgpointcloud/pointcloud/archive/master.tar.gz | tar xz && \
|
|
cd pointcloud-master && \
|
|
./autogen.sh && ./configure && make -j 4 && make install && \
|
|
cd .. && rm -Rf pointcloud-master
|
|
|
|
# Cleanup resources
|
|
RUN apt-get -y --purge autoremove \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Open port 5432 so linked containers can see them
|
|
EXPOSE 5432
|
|
|
|
# Copy scripts
|
|
ADD scripts /scripts
|
|
WORKDIR /scripts
|
|
RUN chmod +x *.sh
|
|
|
|
# Run any additional tasks here that are too tedious to put in
|
|
# this dockerfile directly.
|
|
RUN set -eux \
|
|
&& /scripts/setup.sh
|
|
|
|
VOLUME /var/lib/postgresql
|
|
|
|
ENTRYPOINT /scripts/docker-entrypoint.sh
|