From 70c616fa8e7aa274e500f63bc919d694975f4e61 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 14 Dec 2024 23:15:00 +0100 Subject: [PATCH] cleanup --- Dockerfile | 114 +++++++++++++++++++++---------------------- docker-entrypoint.sh | 4 +- 2 files changed, 57 insertions(+), 61 deletions(-) diff --git a/Dockerfile b/Dockerfile index f874f81..119a25d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,24 +5,35 @@ # Alpine ## -# Use latest Alpine docker release +# Use fix Alpine docker release FROM alpine:3.21.0 +# Select Dotclear release canal (stable | unstable) +ARG CANAL stable + +# Set environment variables +ENV DC_DOCKER_CANAL=$CANAL \ + DC_DOCKER_PHP=php84 \ + DC_DOCKER_PLUGIN_DOCLEARWATCH=0.9.3 \ + DC_DOCKER_PLUGIN_DCLOG=1.7.3 \ + DC_DOCKER_PLUGIN_SYSINFO=10.3 \ + DC_RC_PATH=/var/www/dotclear/config.php \ + DC_PLUGINS_ROOT=/var/www/dotclear/plugins \ + DC_TPL_CACHE=/var/www/dotclear/cache \ + DC_VAR=/var/www/dotclear/var + +# Image label +LABEL "org.opencontainers.image.authors"="Jean-Christian Paul Denis" \ + "org.opencontainers.image.source"="https://github.com/JcDenis/docker-dotclear" \ + "org.opencontainers.image.description"="Dotclear docker image $DC_DOCKER_CANAL" \ + "org.opencontainers.image.licenses"="AGPL-3.0" + # Set system timezone RUN echo "UTC" > /etc/timezone -# Select Dotclear release canal (stable | unstable) -ARG CANAL stable -ENV CNL_DOTCLEAR=$CANAL - # Create user RUN adduser -D -g 'www' www -# Image label -LABEL "org.opencontainers.image.authors"="Jean-Christian Paul Denis" -LABEL "org.opencontainers.image.source"="https://github.com/JcDenis/docker-dotclear" -LABEL "org.opencontainers.image.description"="Dotclear docker image $CNL_DOTCLEAR" -LABEL "org.opencontainers.image.licenses"="AGPL-3.0" ## # Nginx @@ -35,7 +46,6 @@ RUN apk add --no-cache --update \ tar \ unzip \ libxml2-utils - #xq # Create directories structure RUN mkdir -p /var/www/dotclear \ @@ -50,46 +60,44 @@ COPY etc/snippets_common.conf /etc/nginx/snippets/snippets_common.conf # Fix vuln alpine 3.21.0 : curl 8.11.0-r2 => 8.11-r0 RUN apk upgrade curl + ## # PHP ## # Try to bypass Alpine Linux iconv bug -#RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ gnu-libiconv RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.12/community/ gnu-libiconv=1.15-r2 ENV LD_PRELOAD=/usr/lib/preloadable_libiconv.so -# Use PHP 8.4 release -ENV VER_PHP=php84 - # Install PHP required packages RUN apk add --no-cache --update \ - ${VER_PHP}-common \ - ${VER_PHP}-cli \ - ${VER_PHP}-fpm \ - ${VER_PHP}-session \ - ${VER_PHP}-curl \ - ${VER_PHP}-gd \ - ${VER_PHP}-gmp \ - ${VER_PHP}-exif \ - ${VER_PHP}-tidy \ - ${VER_PHP}-intl \ - ${VER_PHP}-json \ - ${VER_PHP}-mbstring \ - ${VER_PHP}-iconv \ - ${VER_PHP}-gettext \ - ${VER_PHP}-mysqli \ - ${VER_PHP}-pgsql \ - ${VER_PHP}-opcache \ - ${VER_PHP}-dom \ - ${VER_PHP}-xml \ - ${VER_PHP}-simplexml \ - ${VER_PHP}-zip \ - ${VER_PHP}-pdo_sqlite + ${DC_DOCKER_PHP}-common \ + ${DC_DOCKER_PHP}-cli \ + ${DC_DOCKER_PHP}-fpm \ + ${DC_DOCKER_PHP}-session \ + ${DC_DOCKER_PHP}-curl \ + ${DC_DOCKER_PHP}-gd \ + ${DC_DOCKER_PHP}-gmp \ + ${DC_DOCKER_PHP}-exif \ + ${DC_DOCKER_PHP}-tidy \ + ${DC_DOCKER_PHP}-intl \ + ${DC_DOCKER_PHP}-json \ + ${DC_DOCKER_PHP}-mbstring \ + ${DC_DOCKER_PHP}-iconv \ + ${DC_DOCKER_PHP}-gettext \ + ${DC_DOCKER_PHP}-mysqli \ + ${DC_DOCKER_PHP}-pgsql \ + ${DC_DOCKER_PHP}-opcache \ + ${DC_DOCKER_PHP}-dom \ + ${DC_DOCKER_PHP}-xml \ + ${DC_DOCKER_PHP}-simplexml \ + ${DC_DOCKER_PHP}-zip \ + ${DC_DOCKER_PHP}-pdo_sqlite # Copy PHP configuration -COPY etc/${CNL_DOTCLEAR}-php.ini /etc/${VER_PHP}/php.ini -COPY etc/php-fpm.conf /etc/${VER_PHP}/php-fpm.d/www.conf +COPY etc/${DC_DOCKER_CANAL}-php.ini /etc/${DC_DOCKER_PHP}/php.ini +COPY etc/php-fpm.conf /etc/${DC_DOCKER_PHP}/php-fpm.d/www.conf + ## # Dotclear @@ -97,8 +105,8 @@ COPY etc/php-fpm.conf /etc/${VER_PHP}/php-fpm.d/www.conf # Download latest Dotclear version RUN curl -fsSL -o versions.xml "http://download.dotclear.org/versions.xml" \ - && curl -fsSL -o dotclear.zip $(xmllint --xpath "//release[@name='$CNL_DOTCLEAR']/@href" versions.xml | awk -F'[="]' '!/>/{print $(NF-1)}') \ - && echo "$(xmllint --xpath "//release[@name='$CNL_DOTCLEAR']/@checksum" versions.xml | awk -F'[="]' '!/>/{print $(NF-1)}') dotclear.zip" | md5sum -c - \ + && curl -fsSL -o dotclear.zip $(xmllint --xpath "//release[@name='$DC_DOCKER_CANAL']/@href" versions.xml | awk -F'[="]' '!/>/{print $(NF-1)}') \ + && echo "$(xmllint --xpath "//release[@name='$DC_DOCKER_CANAL']/@checksum" versions.xml | awk -F'[="]' '!/>/{print $(NF-1)}') dotclear.zip" | md5sum -c - \ && mkdir -p /usr/src/dotclear \ && unzip -d /usr/src dotclear.zip \ && rm dotclear.zip @@ -106,48 +114,36 @@ RUN curl -fsSL -o versions.xml "http://download.dotclear.org/versions.xml" \ # Create predefined www structure COPY www /var/lib/dotclear -# These variables are only used for first install, see inc/config.php, from dotclear 2.32 -# Custom path for dotclear config file -ENV DC_RC_PATH=/var/www/dotclear/config.php -# Directory of third party plugins -ENV DC_PLUGINS_ROOT=/var/www/dotclear/plugins -# Directory for template cache files -ENV DC_TPL_CACHE=/var/www/dotclear/cache -# Directory for dotclear var -ENV DC_VAR=/var/www/dotclear/var ## # Plugins ## # DotclearWatch -ENV VER_PLUGIN_DW=0.9.3 -RUN curl -fsSL -o plugin.zip "https://github.com/JcDenis/DotclearWatch/releases/download/v$VER_PLUGIN_DW/plugin-DotclearWatch.zip" \ +RUN curl -fsSL -o plugin.zip "https://github.com/JcDenis/DotclearWatch/releases/download/v$DC_DOCKER_PLUGIN_DOCLEARWATCH/plugin-DotclearWatch.zip" \ && mkdir -p /var/lib/dotclear/plugins/DotclearWatch \ && unzip -d /var/lib/dotclear/plugins plugin.zip \ && rm plugin.zip # dcLog -ENV VER_PLUGIN_DL=1.7.3 -RUN curl -fsSL -o plugin.zip "https://github.com/JcDenis/dcLog/releases/download/v$VER_PLUGIN_DL/plugin-dcLog.zip" \ +RUN curl -fsSL -o plugin.zip "https://github.com/JcDenis/dcLog/releases/download/v$DC_DOCKER_PLUGIN_DCLOG/plugin-dcLog.zip" \ && mkdir -p /var/lib/dotclear/plugins/dcLog \ && unzip -d /var/lib/dotclear/plugins plugin.zip \ && rm plugin.zip # sysInfo -ENV VER_PLUGIN_SI=10.3 -RUN curl -fsSL -o plugin.zip "https://github.com/franck-paul/sysInfo/releases/download/$VER_PLUGIN_SI/plugin-sysInfo-$VER_PLUGIN_SI.zip" \ +RUN curl -fsSL -o plugin.zip "https://github.com/franck-paul/sysInfo/releases/download/$DC_DOCKER_PLUGIN_SYSINFO/plugin-sysInfo-$DC_DOCKER_PLUGIN_SYSINFO.zip" \ && mkdir -p /var/lib/dotclear/plugins/sysInfo \ && unzip -d /var/lib/dotclear/plugins plugin.zip \ && rm plugin.zip -# Fix ownership -RUN chown -R www:www /var/lib/dotclear /usr/src/dotclear - ## # END ## +# Fix ownership +RUN chown -R www:www /var/lib/dotclear /usr/src/dotclear + # Docker container uses port 80 EXPOSE 80 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index ceac6d6..63eab04 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -6,7 +6,7 @@ set -e # Read image version -if [ "$CNL_DOTCLEAR" == "stable" ]; then +if [ "$DC_DOCKER_CANAL" == "stable" ]; then # stable = x.xx.x => x.xx.x export COMPARE_HAYSTACK="s/^\s*\"release_version\":\s*\"\(.*\)\",/\1/p" else @@ -65,7 +65,7 @@ echo >&2 "Updating Dotclear common themes..." cp -rf /var/www/dotclear/app/themes/* /var/www/dotclear/themes # DEBUG mode for non stable releases -if [ "$CNL_DOTCLEAR" == "stable" ]; then +if [ "$DC_DOCKER_CANAL" == "stable" ]; then echo >&2 "Disabling Dotclear DEBUG mode" sed -i -e "s/ \/\/\*== DC_DEBUG ==/ \/\*== DC_DEBUG ==/g" /var/www/dotclear/app/src/Config.php else