From 52b436657fa035bd50f38a87235a3095fe37fa62 Mon Sep 17 00:00:00 2001 From: Ploc <391-ploc@users.noreply.framagit.org> Date: Fri, 18 Jun 2021 18:28:19 +0200 Subject: [PATCH] fix: follow hadolint hints Follow hadolint best practices in order to have a docker build that is as reliable as possible. - first best practice is to "Pin versions in apk add. Instead of `apk add ` use `apk add =`" (see [DL3018](https://github.com/hadolint/hadolint/wiki/DL3018)) - second best practice is to use "`--no-cache` switch to avoid the need to use `--update`" --- Dockerfile | 20 ++++++++++++++++++-- docker/entrypoint.sh | 6 +++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2dc9be7..e809dcb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,8 +19,24 @@ COPY . /home/lutim RUN chmod -R g+rwX /home/lutim WORKDIR /home/lutim -RUN apk --update add perl libpq perl-crypt-rijndael perl-io-socket-ssl perl-net-ssleay su-exec shared-mime-info libretls imagemagick imagemagick-perlmagick \ - && apk --update add --virtual .build-deps build-base perl-utils perl-dev postgresql14-dev vim wget zlib-dev \ +RUN apk --no-cache add perl~=5 \ + libpq~=14 \ + perl-crypt-rijndael~=1 \ + perl-io-socket-ssl~=2 \ + perl-net-ssleay~=1 \ + su-exec~=0.2 \ + shared-mime-info~=2 \ + libretls~=3 \ + imagemagick~=7 \ + imagemagick-perlmagick~=7 \ + bash~=~5 \ + && apk --no-cache add --virtual .build-deps build-base~=0.5 \ + perl-utils~=5 \ + perl-dev~=5 \ + postgresql14-dev~=14 \ + vim~=8 \ + wget~=1 \ + zlib-dev~=1 \ && cpan notest Carton Config::FromHash \ && carton install --without test \ && apk del .build-deps \ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 4fe4050..360d818 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -eu @@ -14,7 +14,7 @@ then echo "" echo "You can then install the build dependencies with this command" echo " sh ~lutim/docker/install-dev-env.sh" - + tail -f /dev/null exit 0 fi @@ -28,7 +28,7 @@ then DB_HOST=$(perl utilities/read_conf.pl pgdb/host db) DB_PORT=$(perl utilities/read_conf.pl pgdb/port 5432) fi -if [ -n "$DB_HOST" -a -n "$DB_PORT" ] +if [ -n "$DB_HOST" ] && [ -n "$DB_PORT" ] then while ! nc -vz "${DB_HOST}" "${DB_PORT}"; do echo "Waiting for database..."