From 93c0e8787656f85654ba6750adcc3a65c7883031 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 31 Oct 2024 18:31:00 +0100 Subject: [PATCH] initial build commit --- README.md | 1 + debian/nginx/2.31/Dockerfile | 60 +++++++++++++++++++++++ debian/nginx/2.31/docker-compose.yaml | 8 +++ debian/nginx/2.31/docker-entrypoint.sh | 43 ++++++++++++++++ debian/nginx/2.31/server.conf | 37 ++++++++++++++ debian/nginx/docker-compose.yaml | 30 ++++++++++++ debian/nginx/latest/Dockerfile | 62 ++++++++++++++++++++++++ debian/nginx/latest/docker-compose.yaml | 8 +++ debian/nginx/latest/docker-entrypoint.sh | 43 ++++++++++++++++ debian/nginx/latest/server.conf | 37 ++++++++++++++ 10 files changed, 329 insertions(+) create mode 100644 debian/nginx/2.31/Dockerfile create mode 100644 debian/nginx/2.31/docker-compose.yaml create mode 100644 debian/nginx/2.31/docker-entrypoint.sh create mode 100644 debian/nginx/2.31/server.conf create mode 100644 debian/nginx/docker-compose.yaml create mode 100644 debian/nginx/latest/Dockerfile create mode 100644 debian/nginx/latest/docker-compose.yaml create mode 100644 debian/nginx/latest/docker-entrypoint.sh create mode 100644 debian/nginx/latest/server.conf diff --git a/README.md b/README.md index ec1d7e2..b299ae0 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Before Dotclear 2.32, on first run, Dotclear does installation process, you must * MYSQL_DATABASE as database name * MYSQL_USER as database login * MYSQL_PASSWORD as database password + On first run you should wait that container download ans install required version of Dotclear... ## CONTRIBUTING diff --git a/debian/nginx/2.31/Dockerfile b/debian/nginx/2.31/Dockerfile new file mode 100644 index 0000000..aa8c44d --- /dev/null +++ b/debian/nginx/2.31/Dockerfile @@ -0,0 +1,60 @@ +# docker-dotclear:3.31-dnf +# Debian 12.7 / nginx 1.22.1 / php-fpm 8.3 +FROM php:8.3-fpm + +# Dotclear version +ENV DOTCLEAR_VERSION 2.31 +ENV DOTCLEAR_MD5 ec08bbcee14132ac7bcefb8ce5d415ed + +# Required system packages +RUN set -x; \ + apt-get update \ + && apt-get install -y nginx \ + && apt-get install -y --no-install-recommends \ + postgresql-server-dev-all \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libonig-dev \ + rsync \ + unzip \ + && rm -r /var/lib/apt/lists/* + +# Required php packages +RUN docker-php-ext-install opcache mbstring pgsql mysqli \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install gd + +# Opcache +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=2'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/php-opocache-cfg.ini + +# Web server configuartion +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" +COPY server.conf /etc/nginx/conf.d/default.conf + +WORKDIR /var/www/html +EXPOSE 80 + +# Get Dotclear +RUN mkdir -p /usr/src/dotclear \ + && curl -fsSL -o dotclear.zip "http://download.dotclear.org/attic/dotclear-${DOTCLEAR_VERSION}.zip" \ + && echo "$DOTCLEAR_MD5 dotclear.zip" | md5sum -c - \ + && unzip -d /usr/src dotclear.zip \ + && rm dotclear.zip \ + && chown -R www-data:www-data /usr/src/dotclear \ + && chmod -R 755 /usr/src/dotclear/public /usr/src/dotclear/cache \ + && rm -f /var/www/html/* + +# Entrypoint +ADD ../docker-entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] + +# Container healthcheck +HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping || exit 1 \ No newline at end of file diff --git a/debian/nginx/2.31/docker-compose.yaml b/debian/nginx/2.31/docker-compose.yaml new file mode 100644 index 0000000..72b20ac --- /dev/null +++ b/debian/nginx/2.31/docker-compose.yaml @@ -0,0 +1,8 @@ +# docker-dotclear:3.31-dnf +services: + dc_app: + build: + context: . + dockerfile: Dockerfile + image: docker-dotclear:2.31-dnf # debian nginx php-fpm + container_name: dotclear \ No newline at end of file diff --git a/debian/nginx/2.31/docker-entrypoint.sh b/debian/nginx/2.31/docker-entrypoint.sh new file mode 100644 index 0000000..03a4d6e --- /dev/null +++ b/debian/nginx/2.31/docker-entrypoint.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# docker-dotclear:3.31-dnf + +set -e + +# Check if Dotclear exists +if ! [ -e index.php -a -e src/App.php ]; then + # First installation + echo >&2 "Dotclear not found in $(pwd) - copying now..." + if [ "$(ls -A)" ]; then + echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!" + ( set -x; ls -A; sleep 10 ) + fi + tar cf - --one-file-system -C /usr/src/dotclear . | tar xf - + echo >&2 "Complete! Dotclear has been successfully copied to $(pwd)" +else + echo >&2 "Dotclear found in $(pwd), checking upgrade..." + # Check if Dotclear needs upgrade + DOTCLEAR_CURRENT_VERSION=$(sed -n "s/^\s*\"release_version\":\s*\"\(.*\)\",/\1/p" release.json) + if [ "$DOTCLEAR_CURRENT_VERSION" != "$DOTCLEAR_VERSION" ]; then + echo >&2 "Upgrading Dotclear files from ${DOTCLEAR_CURRENT_VERSION} to ${DOTCLEAR_VERSION}, please wait..." + tar cf - --one-file-system -C /usr/src/dotclear . | tar xf - + echo >&2 "Complete! Dotclear files have been successfully upgraded to ${DOTCLEAR_VERSION}" + else + echo >&2 "No need to upgrade Dotclear ${DOTCLEAR_VERSION}" + fi +fi + +# Permissions +chown -R www-data:www-data /var/www/html + +# Summary +echo >&2 "Starting services..." +echo >&2 "Debian $(cat /etc/debian_version)" +echo >&2 "$(nginx -v)PHP: $(php -r "echo PHP_VERSION;")" +echo >&2 "Dotclear: ${DOTCLEAR_VERSION}" + +# Start services (in right order) +php-fpm -D +nginx -g 'daemon off;' + +exec "$@" \ No newline at end of file diff --git a/debian/nginx/2.31/server.conf b/debian/nginx/2.31/server.conf new file mode 100644 index 0000000..92512dd --- /dev/null +++ b/debian/nginx/2.31/server.conf @@ -0,0 +1,37 @@ +# docker-dotclear:3.31-dnf +# nginx php-fpm server configuration to rewrite Dotclear's URL +server { + listen 80; + server_name localhost; + root /var/www/html; + + index index.php; + + location ~ ^/(db|cache|plugins|inc) { + deny all; + return 404; + } + + location / { + try_files $uri $uri/ @dotclear_path_info; + } + + location @dotclear_path_info { + rewrite ^/(.*) /index.php/$1 last; + } + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + } +} \ No newline at end of file diff --git a/debian/nginx/docker-compose.yaml b/debian/nginx/docker-compose.yaml new file mode 100644 index 0000000..8c6e944 --- /dev/null +++ b/debian/nginx/docker-compose.yaml @@ -0,0 +1,30 @@ +services: + + # MYSQL database service + dc_db: + image: mariadb:latest + container_name: dotcleardb + restart: always + command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW + volumes: + - dc_db:/var/lib/mysql + environment: + MYSQL_ROOT_PASSWORD: dotclear_root + MYSQL_DATABASE: dotclear_db + MYSQL_USER: dotclear_user + MYSQL_PASSWORD: dotclear_pwd + + # PHP-FPM Service + dc_app: + image: jcpd/docker-dotclear:latest + container_name: dotclearphp + volumes: + - dc__app:/var/www/html + ports: + - 8080:80 + depends_on: + - dc_db # MYSQL database service + +volumes: + dc_app: # NGINX volume + dc_db: # MYSQL volume \ No newline at end of file diff --git a/debian/nginx/latest/Dockerfile b/debian/nginx/latest/Dockerfile new file mode 100644 index 0000000..ca9595e --- /dev/null +++ b/debian/nginx/latest/Dockerfile @@ -0,0 +1,62 @@ +# docker-dotclear:latest +# Debian 12.7 / nginx 1.22.1 / php-fpm 8.3 + +# Base from PHP official FPM image +FROM php:8.3-fpm + +# Dotclear version +ENV DOTCLEAR_VERSION 2.31 +ENV DOTCLEAR_MD5 ec08bbcee14132ac7bcefb8ce5d415ed + +# Required system packages +RUN set -x; \ + apt-get update \ + && apt-get install -y nginx \ + && apt-get install -y --no-install-recommends \ + postgresql-server-dev-all \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libonig-dev \ + rsync \ + unzip \ + && rm -r /var/lib/apt/lists/* + +# Required php packages +RUN docker-php-ext-install opcache mbstring pgsql mysqli \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install gd + +# Opcache +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=2'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/php-opocache-cfg.ini + +# Web server configuartion +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" +COPY server.conf /etc/nginx/conf.d/default.conf + +WORKDIR /var/www/html +EXPOSE 80 + +# Get Dotclear +RUN mkdir -p /usr/src/dotclear \ + && curl -fsSL -o dotclear.zip "http://download.dotclear.org/attic/dotclear-${DOTCLEAR_VERSION}.zip" \ + && echo "$DOTCLEAR_MD5 dotclear.zip" | md5sum -c - \ + && unzip -d /usr/src dotclear.zip \ + && rm dotclear.zip \ + && chown -R www-data:www-data /usr/src/dotclear \ + && chmod -R 755 /usr/src/dotclear/public /usr/src/dotclear/cache \ + && rm -f /var/www/html/* + +# Entrypoint +ADD ../docker-entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] + +# Container healthcheck +HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping || exit 1 \ No newline at end of file diff --git a/debian/nginx/latest/docker-compose.yaml b/debian/nginx/latest/docker-compose.yaml new file mode 100644 index 0000000..b04ff11 --- /dev/null +++ b/debian/nginx/latest/docker-compose.yaml @@ -0,0 +1,8 @@ +# docker-dotclear:latest +services: + dc_app: + build: + context: . + dockerfile: Dockerfile + image: docker-dotclear:latest # debian nginx php-fpm + container_name: dotclear \ No newline at end of file diff --git a/debian/nginx/latest/docker-entrypoint.sh b/debian/nginx/latest/docker-entrypoint.sh new file mode 100644 index 0000000..1479146 --- /dev/null +++ b/debian/nginx/latest/docker-entrypoint.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# docker-dotclear:latest + +set -e + +# Check if Dotclear exists +if ! [ -e index.php -a -e src/App.php ]; then + # First installation + echo >&2 "Dotclear not found in $(pwd) - copying now..." + if [ "$(ls -A)" ]; then + echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!" + ( set -x; ls -A; sleep 10 ) + fi + tar cf - --one-file-system -C /usr/src/dotclear . | tar xf - + echo >&2 "Complete! Dotclear has been successfully copied to $(pwd)" +else + echo >&2 "Dotclear found in $(pwd), checking upgrade..." + # Check if Dotclear needs upgrade + DOTCLEAR_CURRENT_VERSION=$(sed -n "s/^\s*\"release_version\":\s*\"\(.*\)\",/\1/p" release.json) + if [ "$DOTCLEAR_CURRENT_VERSION" != "$DOTCLEAR_VERSION" ]; then + echo >&2 "Upgrading Dotclear files from ${DOTCLEAR_CURRENT_VERSION} to ${DOTCLEAR_VERSION}, please wait..." + tar cf - --one-file-system -C /usr/src/dotclear . | tar xf - + echo >&2 "Complete! Dotclear files have been successfully upgraded to ${DOTCLEAR_VERSION}" + else + echo >&2 "No need to upgrade Dotclear ${DOTCLEAR_VERSION}" + fi +fi + +# Permissions +chown -R www-data:www-data /var/www/html + +# Summary +echo >&2 "Starting services..." +echo >&2 "Debian $(cat /etc/debian_version)" +echo >&2 "$(nginx -v)PHP: $(php -r "echo PHP_VERSION;")" +echo >&2 "Dotclear: ${DOTCLEAR_VERSION}" + +# Start services (in right order) +php-fpm -D +nginx -g 'daemon off;' + +exec "$@" \ No newline at end of file diff --git a/debian/nginx/latest/server.conf b/debian/nginx/latest/server.conf new file mode 100644 index 0000000..f1cdc71 --- /dev/null +++ b/debian/nginx/latest/server.conf @@ -0,0 +1,37 @@ +# docker-dotclear:latest +# nginx php-fpm server configuration to rewrite Dotclear's URL +server { + listen 80; + server_name localhost; + root /var/www/html; + + index index.php; + + location ~ ^/(db|cache|plugins|inc) { + deny all; + return 404; + } + + location / { + try_files $uri $uri/ @dotclear_path_info; + } + + location @dotclear_path_info { + rewrite ^/(.*) /index.php/$1 last; + } + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + } +} \ No newline at end of file