Add system user to avoid running container with root

For backwards compatilibity, we only set the new user as default in the 2.4 pre-releases.
This commit is contained in:
ToadCast authored and Tianon Gravi committed 2020-12-21 13:10:50 -08:00
1 parent 1c9d1b1016
commit 82ff028a25
17 files changed
+263 -32

No files matched your search

+15 -2
View File
@@ -1,6 +1,17 @@
# vim:set ft=dockerfile:
FROM debian:buster-slim
# roughly, https://salsa.debian.org/haproxy-team/haproxy/-/blob/732b97ae286906dea19ab5744cf9cf97c364ac1d/debian/haproxy.postinst#L5-6
RUN set -eux; \
groupadd --gid 99 --system haproxy; \
useradd \
--gid haproxy \
--home-dir /var/lib/haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 1.7.12
ENV HAPROXY_URL https://www.haproxy.org/download/1.7/src/haproxy-1.7.12.tar.gz
ENV HAPROXY_SHA256 4118178b553a107b227f3f84774c7a50ae0b3ac2be39211c3db511ed4efe48ce
@@ -71,6 +82,8 @@ RUN set -eux; \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+16 -2
View File
@@ -1,6 +1,18 @@
# vim:set ft=dockerfile:
FROM alpine:3.12
# roughly, https://git.alpinelinux.org/aports/tree/main/haproxy/haproxy.pre-install?h=3.12-stable
RUN set -eux; \
addgroup --gid 99 --system haproxy; \
adduser \
--disabled-password \
--home /var/lib/haproxy \
--ingroup haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 1.7.12
ENV HAPROXY_URL https://www.haproxy.org/download/1.7/src/haproxy-1.7.12.tar.gz
ENV HAPROXY_SHA256 4118178b553a107b227f3f84774c7a50ae0b3ac2be39211c3db511ed4efe48ce
@@ -62,6 +74,8 @@ RUN set -x \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+15 -2
View File
@@ -1,6 +1,17 @@
# vim:set ft=dockerfile:
FROM debian:buster-slim
# roughly, https://salsa.debian.org/haproxy-team/haproxy/-/blob/732b97ae286906dea19ab5744cf9cf97c364ac1d/debian/haproxy.postinst#L5-6
RUN set -eux; \
groupadd --gid 99 --system haproxy; \
useradd \
--gid haproxy \
--home-dir /var/lib/haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 1.8.27
ENV HAPROXY_URL https://www.haproxy.org/download/1.8/src/haproxy-1.8.27.tar.gz
ENV HAPROXY_SHA256 56ba6a21e13215fae56472ad37d5d68c3f19bde9da94c59e70b869eecf48bf50
@@ -71,6 +82,8 @@ RUN set -eux; \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+16 -2
View File
@@ -1,6 +1,18 @@
# vim:set ft=dockerfile:
FROM alpine:3.12
# roughly, https://git.alpinelinux.org/aports/tree/main/haproxy/haproxy.pre-install?h=3.12-stable
RUN set -eux; \
addgroup --gid 99 --system haproxy; \
adduser \
--disabled-password \
--home /var/lib/haproxy \
--ingroup haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 1.8.27
ENV HAPROXY_URL https://www.haproxy.org/download/1.8/src/haproxy-1.8.27.tar.gz
ENV HAPROXY_SHA256 56ba6a21e13215fae56472ad37d5d68c3f19bde9da94c59e70b869eecf48bf50
@@ -61,6 +73,8 @@ RUN set -x \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+15 -2
View File
@@ -1,6 +1,17 @@
# vim:set ft=dockerfile:
FROM debian:buster-slim
# roughly, https://salsa.debian.org/haproxy-team/haproxy/-/blob/732b97ae286906dea19ab5744cf9cf97c364ac1d/debian/haproxy.postinst#L5-6
RUN set -eux; \
groupadd --gid 99 --system haproxy; \
useradd \
--gid haproxy \
--home-dir /var/lib/haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.0.19
ENV HAPROXY_URL https://www.haproxy.org/download/2.0/src/haproxy-2.0.19.tar.gz
ENV HAPROXY_SHA256 dcc444ac0aca0917e289653134333f7c29d05d844e6cd60dd04e23b5ff80c92d
@@ -73,6 +84,8 @@ RUN set -eux; \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+16 -2
View File
@@ -1,6 +1,18 @@
# vim:set ft=dockerfile:
FROM alpine:3.12
# roughly, https://git.alpinelinux.org/aports/tree/main/haproxy/haproxy.pre-install?h=3.12-stable
RUN set -eux; \
addgroup --gid 99 --system haproxy; \
adduser \
--disabled-password \
--home /var/lib/haproxy \
--ingroup haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.0.19
ENV HAPROXY_URL https://www.haproxy.org/download/2.0/src/haproxy-2.0.19.tar.gz
ENV HAPROXY_SHA256 dcc444ac0aca0917e289653134333f7c29d05d844e6cd60dd04e23b5ff80c92d
@@ -63,6 +75,8 @@ RUN set -x \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+15 -2
View File
@@ -1,6 +1,17 @@
# vim:set ft=dockerfile:
FROM debian:buster-slim
# roughly, https://salsa.debian.org/haproxy-team/haproxy/-/blob/732b97ae286906dea19ab5744cf9cf97c364ac1d/debian/haproxy.postinst#L5-6
RUN set -eux; \
groupadd --gid 99 --system haproxy; \
useradd \
--gid haproxy \
--home-dir /var/lib/haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.1.10
ENV HAPROXY_URL https://www.haproxy.org/download/2.1/src/haproxy-2.1.10.tar.gz
ENV HAPROXY_SHA256 d245a06145d1d0cbe62681de84bc23dfc98afe10f8cc5c1422a447722a142a41
@@ -73,6 +84,8 @@ RUN set -eux; \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+16 -2
View File
@@ -1,6 +1,18 @@
# vim:set ft=dockerfile:
FROM alpine:3.12
# roughly, https://git.alpinelinux.org/aports/tree/main/haproxy/haproxy.pre-install?h=3.12-stable
RUN set -eux; \
addgroup --gid 99 --system haproxy; \
adduser \
--disabled-password \
--home /var/lib/haproxy \
--ingroup haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.1.10
ENV HAPROXY_URL https://www.haproxy.org/download/2.1/src/haproxy-2.1.10.tar.gz
ENV HAPROXY_SHA256 d245a06145d1d0cbe62681de84bc23dfc98afe10f8cc5c1422a447722a142a41
@@ -63,6 +75,8 @@ RUN set -x \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+15 -2
View File
@@ -1,6 +1,17 @@
# vim:set ft=dockerfile:
FROM debian:buster-slim
# roughly, https://salsa.debian.org/haproxy-team/haproxy/-/blob/732b97ae286906dea19ab5744cf9cf97c364ac1d/debian/haproxy.postinst#L5-6
RUN set -eux; \
groupadd --gid 99 --system haproxy; \
useradd \
--gid haproxy \
--home-dir /var/lib/haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.2.6
ENV HAPROXY_URL https://www.haproxy.org/download/2.2/src/haproxy-2.2.6.tar.gz
ENV HAPROXY_SHA256 be1c6754cbaceafc4837e0c6036c7f81027a3992516435cbbbc5dc749bf5a087
@@ -73,6 +84,8 @@ RUN set -eux; \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+16 -2
View File
@@ -1,6 +1,18 @@
# vim:set ft=dockerfile:
FROM alpine:3.12
# roughly, https://git.alpinelinux.org/aports/tree/main/haproxy/haproxy.pre-install?h=3.12-stable
RUN set -eux; \
addgroup --gid 99 --system haproxy; \
adduser \
--disabled-password \
--home /var/lib/haproxy \
--ingroup haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.2.6
ENV HAPROXY_URL https://www.haproxy.org/download/2.2/src/haproxy-2.2.6.tar.gz
ENV HAPROXY_SHA256 be1c6754cbaceafc4837e0c6036c7f81027a3992516435cbbbc5dc749bf5a087
@@ -63,6 +75,8 @@ RUN set -x \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+15 -2
View File
@@ -1,6 +1,17 @@
# vim:set ft=dockerfile:
FROM debian:buster-slim
# roughly, https://salsa.debian.org/haproxy-team/haproxy/-/blob/732b97ae286906dea19ab5744cf9cf97c364ac1d/debian/haproxy.postinst#L5-6
RUN set -eux; \
groupadd --gid 99 --system haproxy; \
useradd \
--gid haproxy \
--home-dir /var/lib/haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.3.2
ENV HAPROXY_URL https://www.haproxy.org/download/2.3/src/haproxy-2.3.2.tar.gz
ENV HAPROXY_SHA256 99cb73bb791a2cd18898d0595e14fdc820a6cbd622c762f4ed83f2884d038fd5
@@ -73,6 +84,8 @@ RUN set -eux; \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+16 -2
View File
@@ -1,6 +1,18 @@
# vim:set ft=dockerfile:
FROM alpine:3.12
# roughly, https://git.alpinelinux.org/aports/tree/main/haproxy/haproxy.pre-install?h=3.12-stable
RUN set -eux; \
addgroup --gid 99 --system haproxy; \
adduser \
--disabled-password \
--home /var/lib/haproxy \
--ingroup haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.3.2
ENV HAPROXY_URL https://www.haproxy.org/download/2.3/src/haproxy-2.3.2.tar.gz
ENV HAPROXY_SHA256 99cb73bb791a2cd18898d0595e14fdc820a6cbd622c762f4ed83f2884d038fd5
@@ -63,6 +75,8 @@ RUN set -x \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+15 -2
View File
@@ -1,6 +1,17 @@
# vim:set ft=dockerfile:
FROM debian:buster-slim
# roughly, https://salsa.debian.org/haproxy-team/haproxy/-/blob/732b97ae286906dea19ab5744cf9cf97c364ac1d/debian/haproxy.postinst#L5-6
RUN set -eux; \
groupadd --gid 99 --system haproxy; \
useradd \
--gid haproxy \
--home-dir /var/lib/haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.4-dev4
ENV HAPROXY_URL https://www.haproxy.org/download/2.4/src/devel/haproxy-2.4-dev4.tar.gz
ENV HAPROXY_SHA256 be583c7058e0dff02b59ce575e5492b4b6b48d8fd176370312fcada807479c0f
@@ -73,6 +84,8 @@ RUN set -eux; \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
USER haproxy
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+16 -2
View File
@@ -1,6 +1,18 @@
# vim:set ft=dockerfile:
FROM alpine:3.12
# roughly, https://git.alpinelinux.org/aports/tree/main/haproxy/haproxy.pre-install?h=3.12-stable
RUN set -eux; \
addgroup --gid 99 --system haproxy; \
adduser \
--disabled-password \
--home /var/lib/haproxy \
--ingroup haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION 2.4-dev4
ENV HAPROXY_URL https://www.haproxy.org/download/2.4/src/devel/haproxy-2.4-dev4.tar.gz
ENV HAPROXY_SHA256 be583c7058e0dff02b59ce575e5492b4b6b48d8fd176370312fcada807479c0f
@@ -63,6 +75,8 @@ RUN set -x \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
USER haproxy
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+17 -2
View File
@@ -1,6 +1,18 @@
# vim:set ft=dockerfile:
FROM alpine:%%ALPINE_VERSION%%
# roughly, https://git.alpinelinux.org/aports/tree/main/haproxy/haproxy.pre-install?h=3.12-stable
RUN set -eux; \
addgroup --gid 99 --system haproxy; \
adduser \
--disabled-password \
--home /var/lib/haproxy \
--ingroup haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION %%HAPROXY_VERSION%%
ENV HAPROXY_URL %%HAPROXY_URL%%
ENV HAPROXY_SHA256 %%HAPROXY_SHA256%%
@@ -63,6 +75,9 @@ RUN set -x \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
USER haproxy
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+16 -2
View File
@@ -1,6 +1,17 @@
# vim:set ft=dockerfile:
FROM debian:%%DEBIAN_VERSION%%
# roughly, https://salsa.debian.org/haproxy-team/haproxy/-/blob/732b97ae286906dea19ab5744cf9cf97c364ac1d/debian/haproxy.postinst#L5-6
RUN set -eux; \
groupadd --gid 99 --system haproxy; \
useradd \
--gid haproxy \
--home-dir /var/lib/haproxy \
--no-create-home \
--system \
--uid 99 \
haproxy
ENV HAPROXY_VERSION %%HAPROXY_VERSION%%
ENV HAPROXY_URL %%HAPROXY_URL%%
ENV HAPROXY_SHA256 %%HAPROXY_SHA256%%
@@ -73,6 +84,9 @@ RUN set -eux; \
# "graceful stop is triggered when the SIGUSR1 signal is sent to the haproxy process"
STOPSIGNAL SIGUSR1
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
USER haproxy
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
+13
View File
@@ -69,6 +69,19 @@ for version in "${versions[@]}"; do
s/linux-musl/linux-glibc/;
'
fi
case "$version" in
1.* | 2.0 | 2.1 | 2.2 | 2.3)
# backwards compatibility (to try to avoid breaking existing users)
sedExpr+='
/^USER /d
'
;;
*)
sedExpr+='
/backwards compat/d
'
;;
esac
sed -r "$sedExpr" 'Dockerfile-debian.template' > "$version/Dockerfile"
for variant in alpine; do