From 3a05b7e83218aac8f1f75115138cb6a4724209bb Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 22 Sep 2021 02:18:12 -0500 Subject: [PATCH] docker: add less and tini to base image. Add `less` to the Docker image to fix an issue with running `bin/rails console`. The console uses Pry[1], which has an issue where it pipes long output through `less`, but it tries to use the -X option, which is only supported by GNU less, not Busybox less. There's a open bug about this in the Pry repo dating back to 2014[2]. Add `tini` and use it as the Docker entrypoint to ensure we forward signals to child processes and reap zombie children properly. This fixes an issue where if you ran something like: docker run ghcr.io/danbooru/danbooru bash -c 'bin/rails db:test:prepare && bin/rails test' Then you couldn't use control-C to stop the container. This was because bash wasn't forwarding signals to its children, and because by default, programs running as PID 1 ignore SIGINT and SIGTERM. See [3][4] for details. 1: https://github.com/pry/pry 2: https://github.com/pry/pry/issues.1248 3: https://github.com/krallin/tini/issues.8 4: https://gist.github.com/StevenACoffman/41fee08e8782b411a4a26b9700ad7af5#dont-run-pid-1 --- config/docker/Dockerfile.danbooru | 1 + config/docker/build-base-image.sh | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/docker/Dockerfile.danbooru b/config/docker/Dockerfile.danbooru index d1b141f9e..abea737ee 100644 --- a/config/docker/Dockerfile.danbooru +++ b/config/docker/Dockerfile.danbooru @@ -63,6 +63,7 @@ COPY --from=development /root /root COPY --from=assets /danbooru /danbooru USER danbooru +ENTRYPOINT ["tini", "--"] CMD ["bin/rails", "server"] # https://github.com/opencontainers/image-spec/blob/main/annotations.md diff --git a/config/docker/build-base-image.sh b/config/docker/build-base-image.sh index 0280aadad..a915215f6 100755 --- a/config/docker/build-base-image.sh +++ b/config/docker/build-base-image.sh @@ -22,7 +22,9 @@ DANBOORU_RUNTIME_DEPS=" ca-certificates mkvtoolnix postgresql-client-12 libpq5 zlib1g libfftw3-3 libwebp6 libwebpmux3 libwebpdemux2 liborc-0.4.0 liblcms2-2 libpng16-16 libjpeg-turbo8 libexpat1 libglib2.0 libgif7 libexif12 libvpx6 - busybox $EXIFTOOL_RUNTIME_DEPS +" +COMMON_RUNTIME_DEPS=" + $DANBOORU_RUNTIME_DEPS $EXIFTOOL_RUNTIME_DEPS tini busybox less ncdu " apt_install() { @@ -130,7 +132,7 @@ cleanup() { } apt-get update -apt_install $COMMON_BUILD_DEPS $DANBOORU_RUNTIME_DEPS +apt_install $COMMON_BUILD_DEPS $COMMON_RUNTIME_DEPS install_asdf install_exiftool install_ffmpeg