You've already forked postgres
mirror of
https://github.com/docker-library/postgres.git
synced 2025-11-19 00:22:57 +03:00
Merge pull request #330 from infosiftr/multiarch
Use "apt-get source --compile" to build for Debian architectures upstream doesn't
This commit is contained in:
@@ -15,7 +15,7 @@ RUN set -ex; \
|
||||
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
ENV GOSU_VERSION 1.7
|
||||
ENV GOSU_VERSION 1.10
|
||||
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)" \
|
||||
@@ -49,18 +49,73 @@ RUN set -ex; \
|
||||
ENV PG_MAJOR 10
|
||||
ENV PG_VERSION 10~beta4-1.pgdg90+1
|
||||
|
||||
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y postgresql-common \
|
||||
&& sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \
|
||||
&& apt-get install -y \
|
||||
postgresql-$PG_MAJOR=$PG_VERSION \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN set -ex; \
|
||||
\
|
||||
dpkgArch="$(dpkg --print-architecture)"; \
|
||||
case "$dpkgArch" in \
|
||||
amd64|i386|ppc64el) \
|
||||
# arches officialy built by upstream
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main $PG_MAJOR" > /etc/apt/sources.list.d/pgdg.list; \
|
||||
apt-get update; \
|
||||
;; \
|
||||
*) \
|
||||
# we're on an architecture upstream doesn't officially build for
|
||||
# let's build binaries from their published source packages
|
||||
echo "deb-src http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main $PG_MAJOR" > /etc/apt/sources.list.d/pgdg.list; \
|
||||
\
|
||||
tempDir="$(mktemp -d)"; \
|
||||
cd "$tempDir"; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
\
|
||||
# build .deb files from upstream's source packages (which are verified by apt-get)
|
||||
apt-get update; \
|
||||
apt-get build-dep -y \
|
||||
postgresql-common pgdg-keyring \
|
||||
"postgresql-$PG_MAJOR=$PG_VERSION" \
|
||||
; \
|
||||
DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
|
||||
apt-get source --compile \
|
||||
postgresql-common pgdg-keyring \
|
||||
"postgresql-$PG_MAJOR=$PG_VERSION" \
|
||||
; \
|
||||
# we don't remove APT lists here because they get re-downloaded and removed later
|
||||
\
|
||||
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
|
||||
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
|
||||
apt-mark showmanual | xargs apt-mark auto > /dev/null; \
|
||||
apt-mark manual $savedAptMark; \
|
||||
\
|
||||
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
|
||||
ls -lAFh; \
|
||||
dpkg-scanpackages . > Packages; \
|
||||
grep '^Package: ' Packages; \
|
||||
echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list; \
|
||||
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
|
||||
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
|
||||
# ...
|
||||
# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
|
||||
apt-get -o Acquire::GzipIndexes=false update; \
|
||||
;; \
|
||||
esac; \
|
||||
\
|
||||
apt-get install -y postgresql-common; \
|
||||
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf; \
|
||||
apt-get install -y \
|
||||
"postgresql-$PG_MAJOR=$PG_VERSION" \
|
||||
; \
|
||||
\
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
if [ -n "$tempDir" ]; then \
|
||||
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
|
||||
apt-get purge -y --auto-remove; \
|
||||
rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
|
||||
fi
|
||||
|
||||
# make the sample config easier to munge (and "correct by default")
|
||||
RUN mv -v /usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample /usr/share/postgresql/ \
|
||||
&& ln -sv ../postgresql.conf.sample /usr/share/postgresql/$PG_MAJOR/ \
|
||||
RUN mv -v "/usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample" /usr/share/postgresql/ \
|
||||
&& ln -sv ../postgresql.conf.sample "/usr/share/postgresql/$PG_MAJOR/" \
|
||||
&& 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
|
||||
|
||||
Reference in New Issue
Block a user