FROM robinthoni/debian-multiarch:jessie MAINTAINER Robin Thoni ARG PG_VERSION=9.6.3 ARG PG_MAJOR=9.6 ARG PG_VERSION_=9_6_3 RUN apt-get update && apt-get -y install\ zlib1g\ libreadline6\ wget\ bison\ flex\ tar\ gzip\ libreadline-dev\ make\ zlib1g-dev\ git &&\ apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN wget "https://github.com/postgres/postgres/archive/REL${PG_VERSION_}.tar.gz" &&\ tar xf REL${PG_VERSION_}.tar.gz RUN cd postgres-REL${PG_VERSION_} &&\ ./configure --prefix=/usr/ &&\ make &&\ make install RUN apt-get autoremove -y \ wget\ bison\ flex\ libreadline-dev\ make\ zlib1g-dev\ git &&\ rm -rf REL${PG_VERSION_}.tar.gz postgres-REL${PG_VERSION_} RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres ENV GOSU_VERSION 1.7 RUN set -x \ && apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \ && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \ && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \ && export GNUPGHOME="$(mktemp -d)" \ && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true \ && apt-get purge -y --auto-remove ca-certificates wget RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 ENV LANG en_US.utf8 RUN mkdir -p /docker-entrypoint-initdb.d /usr/share/postgresql/ RUN sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH ENV PGDATA /var/lib/postgresql/data RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" # this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values) VOLUME /var/lib/postgresql/data COPY docker-entrypoint.sh /usr/local/bin/ RUN ln -s usr/local/bin/docker-entrypoint.sh / ENTRYPOINT ["docker-entrypoint.sh"] EXPOSE 5432 CMD ["postgres"]