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
This commit is contained in:
evazion
2021-09-22 02:18:12 -05:00
parent 8738d8a645
commit 3a05b7e832
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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