initial build commit

This commit is contained in:
Jean-Christian Denis 2024-10-31 18:31:00 +01:00
parent 7a45875731
commit 93c0e87876
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
10 changed files with 329 additions and 0 deletions

View file

@ -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

60
debian/nginx/2.31/Dockerfile vendored Normal file
View file

@ -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

8
debian/nginx/2.31/docker-compose.yaml vendored Normal file
View file

@ -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

43
debian/nginx/2.31/docker-entrypoint.sh vendored Normal file
View file

@ -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 "$@"

37
debian/nginx/2.31/server.conf vendored Normal file
View file

@ -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;
}
}

30
debian/nginx/docker-compose.yaml vendored Normal file
View file

@ -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

62
debian/nginx/latest/Dockerfile vendored Normal file
View file

@ -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

View file

@ -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

View file

@ -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 "$@"

37
debian/nginx/latest/server.conf vendored Normal file
View file

@ -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;
}
}