File tree Expand file tree Collapse file tree 23 files changed +109
-56
lines changed
Expand file tree Collapse file tree 23 files changed +109
-56
lines changed Original file line number Diff line number Diff line change @@ -54,10 +54,11 @@ RUN mv -v /usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample /usr/share/post
5454 && ln -sv ../postgresql.conf.sample /usr/share/postgresql/$PG_MAJOR/ \
5555 && sed -ri "s!^#?(listen_addresses)\s *=\s *\S +.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample
5656
57- RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
57+ RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod g+s /var/run/postgresql
5858
5959ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
6060ENV PGDATA /var/lib/postgresql/data
61+ RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 700 "$PGDATA"
6162VOLUME /var/lib/postgresql/data
6263
6364COPY docker-entrypoint.sh /
Original file line number Diff line number Diff line change @@ -55,6 +55,11 @@ RUN set -ex \
5555 zlib-dev \
5656 \
5757 && cd /usr/src/postgresql \
58+ # update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
59+ # see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
60+ && awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\" /tmp\" " { $3 = "\" /var/run/postgresql\" "; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new \
61+ && grep '/var/run/postgresql' src/include/pg_config_manual.h.new \
62+ && mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h \
5863# configure options taken from:
5964# https://anonscm.debian.org/cgit/pkg-postgresql/postgresql.git/tree/debian/rules?h=9.5
6065 && ./configure \
@@ -113,10 +118,11 @@ RUN set -ex \
113118# make the sample config easier to munge (and "correct by default")
114119RUN sed -ri "s!^#?(listen_addresses)\s *=\s *\S +.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample
115120
116- RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
121+ RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod g+s /var/run/postgresql
117122
118123ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
119124ENV PGDATA /var/lib/postgresql/data
125+ RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 700 "$PGDATA"
120126VOLUME /var/lib/postgresql/data
121127
122128COPY docker-entrypoint.sh /
Original file line number Diff line number Diff line change 2929
3030if [ " $1 " = ' postgres' ]; then
3131 mkdir -p " $PGDATA "
32- chmod 700 " $PGDATA "
3332 chown -R postgres " $PGDATA "
33+ chmod 700 " $PGDATA "
34+
35+ mkdir -p /var/run/postgresql
36+ chown -R postgres /var/run/postgresql
37+ chmod g+s /var/run/postgresql
3438
35- mkdir -p /run/postgresql
36- chmod g+s /run/postgresql
37- chown -R postgres /run/postgresql
3839
3940 # look specifically for PG_VERSION, as it is expected in the DB dir
4041 if [ ! -s " $PGDATA /PG_VERSION" ]; then
Original file line number Diff line number Diff line change 2929
3030if [ " $1 " = ' postgres' ]; then
3131 mkdir -p " $PGDATA "
32- chmod 700 " $PGDATA "
3332 chown -R postgres " $PGDATA "
33+ chmod 700 " $PGDATA "
34+
35+ mkdir -p /var/run/postgresql
36+ chown -R postgres /var/run/postgresql
37+ chmod g+s /var/run/postgresql
3438
35- mkdir -p /run/postgresql
36- chmod g+s /run/postgresql
37- chown -R postgres /run/postgresql
3839
3940 # look specifically for PG_VERSION, as it is expected in the DB dir
4041 if [ ! -s " $PGDATA /PG_VERSION" ]; then
Original file line number Diff line number Diff line change @@ -54,10 +54,11 @@ RUN mv -v /usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample /usr/share/post
5454 && ln -sv ../postgresql.conf.sample /usr/share/postgresql/$PG_MAJOR/ \
5555 && sed -ri "s!^#?(listen_addresses)\s *=\s *\S +.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample
5656
57- RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
57+ RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod g+s /var/run/postgresql
5858
5959ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
6060ENV PGDATA /var/lib/postgresql/data
61+ RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 700 "$PGDATA"
6162VOLUME /var/lib/postgresql/data
6263
6364COPY docker-entrypoint.sh /
Original file line number Diff line number Diff line change @@ -55,6 +55,11 @@ RUN set -ex \
5555 zlib-dev \
5656 \
5757 && cd /usr/src/postgresql \
58+ # update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
59+ # see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
60+ && awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\" /tmp\" " { $3 = "\" /var/run/postgresql\" "; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new \
61+ && grep '/var/run/postgresql' src/include/pg_config_manual.h.new \
62+ && mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h \
5863# configure options taken from:
5964# https://anonscm.debian.org/cgit/pkg-postgresql/postgresql.git/tree/debian/rules?h=9.5
6065 && ./configure \
@@ -113,10 +118,11 @@ RUN set -ex \
113118# make the sample config easier to munge (and "correct by default")
114119RUN sed -ri "s!^#?(listen_addresses)\s *=\s *\S +.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample
115120
116- RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
121+ RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod g+s /var/run/postgresql
117122
118123ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
119124ENV PGDATA /var/lib/postgresql/data
125+ RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 700 "$PGDATA"
120126VOLUME /var/lib/postgresql/data
121127
122128COPY docker-entrypoint.sh /
Original file line number Diff line number Diff line change 2929
3030if [ " $1 " = ' postgres' ]; then
3131 mkdir -p " $PGDATA "
32- chmod 700 " $PGDATA "
3332 chown -R postgres " $PGDATA "
33+ chmod 700 " $PGDATA "
34+
35+ mkdir -p /var/run/postgresql
36+ chown -R postgres /var/run/postgresql
37+ chmod g+s /var/run/postgresql
3438
35- mkdir -p /run/postgresql
36- chmod g+s /run/postgresql
37- chown -R postgres /run/postgresql
3839
3940 # look specifically for PG_VERSION, as it is expected in the DB dir
4041 if [ ! -s " $PGDATA /PG_VERSION" ]; then
Original file line number Diff line number Diff line change 2929
3030if [ " $1 " = ' postgres' ]; then
3131 mkdir -p " $PGDATA "
32- chmod 700 " $PGDATA "
3332 chown -R postgres " $PGDATA "
33+ chmod 700 " $PGDATA "
34+
35+ mkdir -p /var/run/postgresql
36+ chown -R postgres /var/run/postgresql
37+ chmod g+s /var/run/postgresql
3438
35- mkdir -p /run/postgresql
36- chmod g+s /run/postgresql
37- chown -R postgres /run/postgresql
3839
3940 # look specifically for PG_VERSION, as it is expected in the DB dir
4041 if [ ! -s " $PGDATA /PG_VERSION" ]; then
Original file line number Diff line number Diff line change @@ -54,10 +54,11 @@ RUN mv -v /usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample /usr/share/post
5454 && ln -sv ../postgresql.conf.sample /usr/share/postgresql/$PG_MAJOR/ \
5555 && sed -ri "s!^#?(listen_addresses)\s *=\s *\S +.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample
5656
57- RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
57+ RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod g+s /var/run/postgresql
5858
5959ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
6060ENV PGDATA /var/lib/postgresql/data
61+ RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 700 "$PGDATA"
6162VOLUME /var/lib/postgresql/data
6263
6364COPY docker-entrypoint.sh /
Original file line number Diff line number Diff line change @@ -55,6 +55,11 @@ RUN set -ex \
5555 zlib-dev \
5656 \
5757 && cd /usr/src/postgresql \
58+ # update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
59+ # see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
60+ && awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\" /tmp\" " { $3 = "\" /var/run/postgresql\" "; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new \
61+ && grep '/var/run/postgresql' src/include/pg_config_manual.h.new \
62+ && mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h \
5863# configure options taken from:
5964# https://anonscm.debian.org/cgit/pkg-postgresql/postgresql.git/tree/debian/rules?h=9.5
6065 && ./configure \
@@ -113,10 +118,11 @@ RUN set -ex \
113118# make the sample config easier to munge (and "correct by default")
114119RUN sed -ri "s!^#?(listen_addresses)\s *=\s *\S +.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample
115120
116- RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
121+ RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod g+s /var/run/postgresql
117122
118123ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
119124ENV PGDATA /var/lib/postgresql/data
125+ RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 700 "$PGDATA"
120126VOLUME /var/lib/postgresql/data
121127
122128COPY docker-entrypoint.sh /
You can’t perform that action at this time.
0 commit comments