From 9e25e43fb98fce36fceb0e12083d73add47acee5 Mon Sep 17 00:00:00 2001 From: valvin Date: Sun, 8 Mar 2020 20:47:56 +0100 Subject: [PATCH] feat(): add tini as process manager --- 2019.12/apache/Dockerfile | 10 ++++++++++ 2019.12/apache/cron.sh | 2 +- 2019.12/fpm-alpine/Dockerfile | 3 ++- 2019.12/fpm-alpine/cron.sh | 2 +- 2019.12/fpm/Dockerfile | 10 ++++++++++ 2019.12/fpm/cron.sh | 2 +- 2020.03-dev/apache/Dockerfile | 10 ++++++++++ 2020.03-dev/apache/cron.sh | 2 +- 2020.03-dev/fpm-alpine/Dockerfile | 3 ++- 2020.03-dev/fpm-alpine/cron.sh | 2 +- 2020.03-dev/fpm/Dockerfile | 10 ++++++++++ 2020.03-dev/fpm/cron.sh | 2 +- Dockerfile-alpine.template | 3 ++- Dockerfile-debian.template | 10 ++++++++++ docker-cron.sh | 2 +- update.sh | 6 +++++- 16 files changed, 68 insertions(+), 11 deletions(-) diff --git a/2019.12/apache/Dockerfile b/2019.12/apache/Dockerfile index 655a7ad..ffc45f5 100644 --- a/2019.12/apache/Dockerfile +++ b/2019.12/apache/Dockerfile @@ -11,9 +11,19 @@ RUN set -ex; \ git \ # For mail() support ssmtp \ +# For tini installation + gnupg dirmngr \ ; \ rm -rf /var/lib/apt/lists/*; +# Add tini for reaping processes +ENV TINI_VERSION v0.18.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc +RUN gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \ + && gpg --batch --verify /tini.asc /sbin/tini \ + && chmod +x /sbin/tini + # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ RUN set -ex; \ diff --git a/2019.12/apache/cron.sh b/2019.12/apache/cron.sh index c2fd1c2..55be04a 100755 --- a/2019.12/apache/cron.sh +++ b/2019.12/apache/cron.sh @@ -7,7 +7,7 @@ done echo "Waiting for MySQL $MYSQL_HOST initialization..." if php /var/www/html/bin/wait-for-connection "$MYSQL_HOST" "${MYSQL_PORT:-3306}" 300; then - php /var/www/html/bin/daemon.php -f start + exec /sbin/tini -- php /var/www/html/bin/daemon.php -f start else echo "[ERROR] Waited 300 seconds, no response" >&2 fi diff --git a/2019.12/fpm-alpine/Dockerfile b/2019.12/fpm-alpine/Dockerfile index 8a29480..5ac077b 100644 --- a/2019.12/fpm-alpine/Dockerfile +++ b/2019.12/fpm-alpine/Dockerfile @@ -8,7 +8,8 @@ RUN set -ex; \ git \ # For mail() support ssmtp \ - shadow; + shadow \ + tini; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ diff --git a/2019.12/fpm-alpine/cron.sh b/2019.12/fpm-alpine/cron.sh index c2fd1c2..55be04a 100755 --- a/2019.12/fpm-alpine/cron.sh +++ b/2019.12/fpm-alpine/cron.sh @@ -7,7 +7,7 @@ done echo "Waiting for MySQL $MYSQL_HOST initialization..." if php /var/www/html/bin/wait-for-connection "$MYSQL_HOST" "${MYSQL_PORT:-3306}" 300; then - php /var/www/html/bin/daemon.php -f start + exec /sbin/tini -- php /var/www/html/bin/daemon.php -f start else echo "[ERROR] Waited 300 seconds, no response" >&2 fi diff --git a/2019.12/fpm/Dockerfile b/2019.12/fpm/Dockerfile index 3262ead..96f4e3b 100644 --- a/2019.12/fpm/Dockerfile +++ b/2019.12/fpm/Dockerfile @@ -11,9 +11,19 @@ RUN set -ex; \ git \ # For mail() support ssmtp \ +# For tini installation + gnupg dirmngr \ ; \ rm -rf /var/lib/apt/lists/*; +# Add tini for reaping processes +ENV TINI_VERSION v0.18.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc +RUN gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \ + && gpg --batch --verify /tini.asc /sbin/tini \ + && chmod +x /sbin/tini + # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ RUN set -ex; \ diff --git a/2019.12/fpm/cron.sh b/2019.12/fpm/cron.sh index c2fd1c2..55be04a 100755 --- a/2019.12/fpm/cron.sh +++ b/2019.12/fpm/cron.sh @@ -7,7 +7,7 @@ done echo "Waiting for MySQL $MYSQL_HOST initialization..." if php /var/www/html/bin/wait-for-connection "$MYSQL_HOST" "${MYSQL_PORT:-3306}" 300; then - php /var/www/html/bin/daemon.php -f start + exec /sbin/tini -- php /var/www/html/bin/daemon.php -f start else echo "[ERROR] Waited 300 seconds, no response" >&2 fi diff --git a/2020.03-dev/apache/Dockerfile b/2020.03-dev/apache/Dockerfile index e52cfbd..317ce17 100644 --- a/2020.03-dev/apache/Dockerfile +++ b/2020.03-dev/apache/Dockerfile @@ -11,9 +11,19 @@ RUN set -ex; \ git \ # For mail() support ssmtp \ +# For tini installation + gnupg dirmngr \ ; \ rm -rf /var/lib/apt/lists/*; +# Add tini for reaping processes +ENV TINI_VERSION v0.18.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc +RUN gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \ + && gpg --batch --verify /tini.asc /sbin/tini \ + && chmod +x /sbin/tini + # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ RUN set -ex; \ diff --git a/2020.03-dev/apache/cron.sh b/2020.03-dev/apache/cron.sh index c2fd1c2..55be04a 100755 --- a/2020.03-dev/apache/cron.sh +++ b/2020.03-dev/apache/cron.sh @@ -7,7 +7,7 @@ done echo "Waiting for MySQL $MYSQL_HOST initialization..." if php /var/www/html/bin/wait-for-connection "$MYSQL_HOST" "${MYSQL_PORT:-3306}" 300; then - php /var/www/html/bin/daemon.php -f start + exec /sbin/tini -- php /var/www/html/bin/daemon.php -f start else echo "[ERROR] Waited 300 seconds, no response" >&2 fi diff --git a/2020.03-dev/fpm-alpine/Dockerfile b/2020.03-dev/fpm-alpine/Dockerfile index 6bf60ad..77c186d 100644 --- a/2020.03-dev/fpm-alpine/Dockerfile +++ b/2020.03-dev/fpm-alpine/Dockerfile @@ -8,7 +8,8 @@ RUN set -ex; \ git \ # For mail() support ssmtp \ - shadow; + shadow \ + tini; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ diff --git a/2020.03-dev/fpm-alpine/cron.sh b/2020.03-dev/fpm-alpine/cron.sh index c2fd1c2..55be04a 100755 --- a/2020.03-dev/fpm-alpine/cron.sh +++ b/2020.03-dev/fpm-alpine/cron.sh @@ -7,7 +7,7 @@ done echo "Waiting for MySQL $MYSQL_HOST initialization..." if php /var/www/html/bin/wait-for-connection "$MYSQL_HOST" "${MYSQL_PORT:-3306}" 300; then - php /var/www/html/bin/daemon.php -f start + exec /sbin/tini -- php /var/www/html/bin/daemon.php -f start else echo "[ERROR] Waited 300 seconds, no response" >&2 fi diff --git a/2020.03-dev/fpm/Dockerfile b/2020.03-dev/fpm/Dockerfile index 7590942..1dba9dc 100644 --- a/2020.03-dev/fpm/Dockerfile +++ b/2020.03-dev/fpm/Dockerfile @@ -11,9 +11,19 @@ RUN set -ex; \ git \ # For mail() support ssmtp \ +# For tini installation + gnupg dirmngr \ ; \ rm -rf /var/lib/apt/lists/*; +# Add tini for reaping processes +ENV TINI_VERSION v0.18.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc +RUN gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \ + && gpg --batch --verify /tini.asc /sbin/tini \ + && chmod +x /sbin/tini + # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ RUN set -ex; \ diff --git a/2020.03-dev/fpm/cron.sh b/2020.03-dev/fpm/cron.sh index c2fd1c2..55be04a 100755 --- a/2020.03-dev/fpm/cron.sh +++ b/2020.03-dev/fpm/cron.sh @@ -7,7 +7,7 @@ done echo "Waiting for MySQL $MYSQL_HOST initialization..." if php /var/www/html/bin/wait-for-connection "$MYSQL_HOST" "${MYSQL_PORT:-3306}" 300; then - php /var/www/html/bin/daemon.php -f start + exec /sbin/tini -- php /var/www/html/bin/daemon.php -f start else echo "[ERROR] Waited 300 seconds, no response" >&2 fi diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 4070d31..f2bb765 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -7,7 +7,8 @@ RUN set -ex; \ git \ # For mail() support ssmtp \ - shadow; + shadow \ + tini; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 8d682e6..ca91689 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -10,9 +10,19 @@ RUN set -ex; \ git \ # For mail() support ssmtp \ +# For tini installation + gnupg dirmngr \ ; \ rm -rf /var/lib/apt/lists/*; +# Add tini for reaping processes +ENV TINI_VERSION v%%TINI_VERSION%% +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc +RUN gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \ + && gpg --batch --verify /tini.asc /sbin/tini \ + && chmod +x /sbin/tini + # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ RUN set -ex; \ diff --git a/docker-cron.sh b/docker-cron.sh index c2fd1c2..55be04a 100755 --- a/docker-cron.sh +++ b/docker-cron.sh @@ -7,7 +7,7 @@ done echo "Waiting for MySQL $MYSQL_HOST initialization..." if php /var/www/html/bin/wait-for-connection "$MYSQL_HOST" "${MYSQL_PORT:-3306}" 300; then - php /var/www/html/bin/daemon.php -f start + exec /sbin/tini -- php /var/www/html/bin/daemon.php -f start else echo "[ERROR] Waited 300 seconds, no response" >&2 fi diff --git a/update.sh b/update.sh index f11632d..cb0e3a6 100755 --- a/update.sh +++ b/update.sh @@ -28,6 +28,9 @@ declare -A entrypoints=( [develop]='entrypoint-dev.sh' ) +# Only for debian variant +tini_version="0.18.0" + apcu_version="$( git ls-remote --tags https://github.com/krakjoe/apcu.git \ | cut -d/ -f3 \ @@ -122,6 +125,7 @@ function create_variant() { s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g; s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g; s/%%ENTRYPOINT%%/'"${entrypoints[$install_type]}"'/g; + s/%%TINI_VERSION%%/'"${tini_version}"'/g; ' "$dir/Dockerfile" for name in entrypoint cron; do @@ -162,4 +166,4 @@ echo "$travisAmd64" > .travis.yml travisFull="$(awk -v 'RS=\n\n' '$1 == "-" && $2 == "stage:" && $3 == "test" && $4 == "images" && $5 == "(full)" { $0 = " - stage: test images (full)'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)" -echo "$travisFull" > .travis.yml \ No newline at end of file +echo "$travisFull" > .travis.yml