From 71ab777d31cc620f064590219733fb7f2e223d6e Mon Sep 17 00:00:00 2001 From: Buster Neece Date: Mon, 31 Oct 2022 06:43:19 -0500 Subject: [PATCH] Optimize Dockerfile; switch to supercronic. --- Dockerfile | 30 ++++------------------ util/docker/stations/setup/icecast.sh | 17 ++++++++++--- util/docker/web/cron/azuracast | 6 ++--- util/docker/web/service.full/cron.conf | 2 +- util/docker/web/setup/cron.sh | 35 +------------------------- util/docker/web/setup/php.sh | 14 +++-------- 6 files changed, 26 insertions(+), 78 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a21de8fe..e72fcb348 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,15 @@ -# -# Icecast build step -# -FROM ubuntu:jammy AS icecast - -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -q -y --no-install-recommends \ - curl git ca-certificates \ - build-essential libxml2 libxslt1-dev libvorbis-dev libssl-dev libcurl4-openssl-dev \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /tmp/install_icecast - -RUN curl -fsSL -o icecast.tar.gz https://github.com/AzuraCast/icecast-kh-ac/archive/refs/tags/2.4.0-kh15-ac2.tar.gz \ - && tar -xzvf icecast.tar.gz --strip-components=1 \ - && ./configure \ - && make \ - && make install - # # Golang dependencies build step # -FROM golang:1-bullseye AS dockerize +FROM golang:1-bullseye AS go-dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends openssl git RUN go install github.com/jwilder/dockerize@latest +RUN go install github.com/aptible/supercronic@latest + # # Final build image # @@ -35,11 +18,8 @@ FROM mariadb:10.9-jammy ENV TZ="UTC" # Add Dockerize -COPY --from=dockerize /go/bin/dockerize /usr/local/bin - -# Import Icecast-KH from build container -COPY --from=icecast /usr/local/bin/icecast /usr/local/bin/icecast -COPY --from=icecast /usr/local/share/icecast /usr/local/share/icecast +COPY --from=go-dependencies /go/bin/dockerize /usr/local/bin +COPY --from=go-dependencies /go/bin/supercronic /usr/local/bin/supercronic # Run base build process COPY ./util/docker/common /bd_build/ diff --git a/util/docker/stations/setup/icecast.sh b/util/docker/stations/setup/icecast.sh index decc8662c..568365c3e 100644 --- a/util/docker/stations/setup/icecast.sh +++ b/util/docker/stations/setup/icecast.sh @@ -2,8 +2,17 @@ set -e set -x -# Only install Icecast deps (Icecast is handled by another container). -apt-get install -y --no-install-recommends libxml2 libxslt1-dev libvorbis-dev +# Build Icecast from source +apt-get install -q -y --no-install-recommends \ + build-essential libxml2 libxslt1-dev libvorbis-dev libssl-dev libcurl4-openssl-dev openssl -# SSL self-signed cert generation -apt-get install -y --no-install-recommends openssl +mkdir -p /bd_build/stations/icecast +cd /bd_build/stations/icecast + +curl -fsSL -o icecast.tar.gz https://github.com/AzuraCast/icecast-kh-ac/archive/refs/tags/2.4.0-kh15-ac2.tar.gz +tar -xzvf icecast.tar.gz --strip-components=1 +./configure +make +make install + +apt-get remove --purge -y build-essential libssl-dev libcurl4-openssl-dev diff --git a/util/docker/web/cron/azuracast b/util/docker/web/cron/azuracast index a97015624..8c840e63f 100644 --- a/util/docker/web/cron/azuracast +++ b/util/docker/web/cron/azuracast @@ -1,4 +1,2 @@ -SHELL=/bin/bash -BASH_ENV=/container.env -* * * * * root /usr/local/bin/cron_task azuracast_cli azuracast:sync:run -30 */6 * * * root /usr/local/bin/temp_cleanup +0 * * * * * * azuracast_cli azuracast:sync:run +0 30 */6 * * * * temp_cleanup diff --git a/util/docker/web/service.full/cron.conf b/util/docker/web/service.full/cron.conf index 2d89b8e42..12112bf4d 100644 --- a/util/docker/web/service.full/cron.conf +++ b/util/docker/web/service.full/cron.conf @@ -1,5 +1,5 @@ [program:cron] -command=/usr/sbin/cron -f +command=supercronic /etc/cron.d/azuracast priority=600 numprocs=1 autostart=true diff --git a/util/docker/web/setup/cron.sh b/util/docker/web/setup/cron.sh index eeb13f094..d4b53a213 100644 --- a/util/docker/web/setup/cron.sh +++ b/util/docker/web/setup/cron.sh @@ -2,38 +2,5 @@ set -e set -x -install_without_postinst() { - local PACKAGE - PACKAGE=$1 - - mkdir -p /tmp/install_$PACKAGE - cd /tmp/install_$PACKAGE - - apt-get download $PACKAGE - dpkg --unpack $PACKAGE*.deb - rm -f /var/lib/dpkg/info/$PACKAGE.postinst - dpkg --configure $PACKAGE - - apt-get install -yf #To fix dependencies - - cd / - rm -rf /tmp/install_$PACKAGE -} - -install_without_postinst cron - -chmod 600 /etc/crontab - -# Fix cron issues in 0.9.19, see also #345: https://github.com/phusion/baseimage-docker/issues/345 -sed -i 's/^\s*session\s\+required\s\+pam_loginuid.so/# &/' /etc/pam.d/cron - -## Remove useless cron entries. -# Checks for lost+found and scans for mtab. -rm -f /etc/cron.daily/standard -rm -f /etc/cron.daily/upstart -rm -f /etc/cron.daily/dpkg -rm -f /etc/cron.daily/password -rm -f /etc/cron.weekly/fstrim - +mkdir -p /etc/cron.d/ cp -r /bd_build/web/cron/. /etc/cron.d/ -chmod -R 600 /etc/cron.d/* diff --git a/util/docker/web/setup/php.sh b/util/docker/web/setup/php.sh index f02c48056..c792f76a4 100644 --- a/util/docker/web/setup/php.sh +++ b/util/docker/web/setup/php.sh @@ -25,19 +25,13 @@ cp /bd_build/web/php/www.conf.tmpl /etc/php/${PHP_VERSION}/fpm/www.conf.tmpl # Install Composer curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer -# Download PHP-FPM healthcheck script -apt-get install -y --no-install-recommends libfcgi-bin - -wget -O /usr/local/bin/php-fpm-healthcheck \ - https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck \ - && chmod +x /usr/local/bin/php-fpm-healthcheck - # Install PHP SPX profiler apt-get install -y --no-install-recommends php${PHP_VERSION}-dev zlib1g-dev build-essential -cd /bd_build -git clone https://github.com/NoiseByNorthwest/php-spx.git -cd php-spx +mkdir -p /bd_build/web/php-spx +cd /bd_build/web/php-spx + +git clone https://github.com/NoiseByNorthwest/php-spx.git . phpize ./configure make