Skip to content

Commit

Permalink
entrypoint: Launch our entrypoint via dumb-init
Browse files Browse the repository at this point in the history
Even single process containers (which this one is actually not) should
have an init system. However most init systems are too big and complex
for containerization purposes. [Dumb-init][0] (and tini init) address
this problem _specifically_ for Docker containers.

See the [dumb-init][0] documentation for more details.

[0]: https://github.com/Yelp/dumb-init

Signed-off-by: Olliver Schinagl <[email protected]>
  • Loading branch information
oliv3r committed Jun 10, 2023
1 parent 10fa7fc commit 2c51119
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Dockerfile-alpine-slim.template
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ RUN set -x \
# forward request and error logs to docker log collector
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
# Ensure we can run our entrypoint
&& apk add --no-cache dumb-init \
# create a docker-entrypoint.d directory
&& mkdir /docker-entrypoint.d

Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-alpine.template
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ RUN set -x \
&& if [ -n "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
&& if [ -n "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi \
# Bring in curl and ca-certificates to make registering on DNS SD easier
&& apk add --no-cache curl ca-certificates
&& apk add --no-cache curl ca-certificates \
# Ensure we can run our entrypoint
&& apk add --no-cache dumb-init
1 change: 1 addition & 0 deletions Dockerfile-debian.template
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ RUN set -x \
$nginxPackages \
gettext-base \
curl \
dumb-init \
&& apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list \
\
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
Expand Down
2 changes: 1 addition & 1 deletion entrypoint/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/dumb-init /bin/sh
# vim:sw=4:ts=4:et

set -e
Expand Down

0 comments on commit 2c51119

Please sign in to comment.