@@ -13,39 +13,22 @@ RUN set -eux; \
1313# see https://github.com/docker-library/postgres/issues/274
1414 install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
1515
16- # grab gosu for easy step-down from root
17- # https://github.com/tianon/gosu/releases
18- ENV GOSU_VERSION 1.17
19- RUN set -eux; \
20- \
21- apk add --no-cache --virtual .gosu-deps \
22- ca-certificates \
23- dpkg \
24- gnupg \
25- ; \
26- \
27- dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
28- wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
29- wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
30- \
31- # verify the signature
32- export GNUPGHOME="$(mktemp -d)"; \
33- gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
34- gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
35- gpgconf --kill all; \
36- rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
37- \
38- # clean up fetch dependencies
39- apk del --no-network .gosu-deps; \
40- \
41- chmod +x /usr/local/bin/gosu; \
42- # verify that the binary works
43- gosu --version; \
44- gosu nobody true
4516{{ if env.version | IN("13", "14", "15", "16") then ( -}}
46- RUN set -eux; ln -svf gosu /usr/local/bin/su-exec; su-exec nobody true # backwards compatibility (removed in PostgreSQL 17+)
17+ # backwards compatibility (removed in PostgreSQL 17+)
18+ RUN set -eux; \
19+ \
20+ apk add --no-cache su-exec; \
21+ echo 'testing su-exec:' ; \
22+ su-exec nobody id
4723{{ ) else "" end -}}
4824
25+ # Install real setpriv from util-linux rather than busybox
26+ RUN set -eux; \
27+ \
28+ apk add --no-cache setpriv; \
29+ echo 'testing setpriv:' ; \
30+ setpriv --reuid=nobody --regid=nobody --clear-groups id
31+
4932# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
5033# alpine doesn't require explicit locale-file generation
5134ENV LANG en_US.utf8
0 commit comments