Skip to content

Commit 722405c

Browse files
author
Dmytro Lukianenko
committed
create docker image dmi3yy/evolution-cms
1 parent 44dff99 commit 722405c

4 files changed

Lines changed: 315 additions & 0 deletions

File tree

.dockerignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# Docker
7+
Dockerfile
8+
.dockerignore
9+
docker-compose.yml
10+
docker-compose.*.yml
11+
12+
# Documentation
13+
README.md
14+
*.md
15+
docs/
16+
17+
# IDE
18+
.idea/
19+
.vscode/
20+
*.swp
21+
*.swo
22+
23+
# OS
24+
.DS_Store
25+
Thumbs.db
26+
27+
# Logs
28+
*.log
29+
logs/
30+
31+
# Temporary files
32+
tmp/
33+
temp/
34+
.tmp/
35+
36+
# Node.js (if any)
37+
node_modules/
38+
npm-debug.log
39+
yarn-error.log
40+
41+
# PHP
42+
.phpunit.result.cache
43+
phpunit.xml
44+
45+
# Environment files
46+
.env
47+
.env.*
48+
49+
# Backup files
50+
*.bak
51+
*.backup
52+
*.sql
53+
54+
# Cache directories
55+
core/storage/cache/*
56+
core/storage/logs/*
57+
core/storage/sessions/*
58+
assets/cache/*
59+
!core/storage/.gitkeep
60+
!assets/cache/.gitkeep
61+
62+
# Vendor (will be installed during build)
63+
# core/vendor/
64+
# vendor/

Dockerfile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
FROM php:8.4-apache
2+
3+
# System deps and PHP extensions
4+
RUN apt-get update && apt-get install -y \
5+
libfreetype6-dev \
6+
libjpeg62-turbo-dev \
7+
libpng-dev \
8+
libzip-dev \
9+
libpq-dev \
10+
libxml2-dev \
11+
libicu-dev \
12+
unzip \
13+
git \
14+
netcat-openbsd \
15+
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
16+
&& docker-php-ext-configure intl \
17+
&& docker-php-ext-install -j$(nproc) \
18+
gd \
19+
mysqli \
20+
pdo \
21+
pdo_mysql \
22+
pdo_pgsql \
23+
pgsql \
24+
zip \
25+
dom \
26+
xml \
27+
simplexml \
28+
mbstring \
29+
iconv \
30+
intl \
31+
opcache \
32+
&& a2enmod rewrite \
33+
&& apt-get clean \
34+
&& rm -rf /var/lib/apt/lists/*
35+
36+
# Composer (use official image for better security)
37+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
38+
39+
# App files
40+
WORKDIR /var/www/html
41+
COPY . /var/www/html
42+
43+
# PHP configuration
44+
COPY docker/php.ini /usr/local/etc/php/conf.d/40-custom.ini
45+
46+
# Build-time Composer optimisation (root if needed, then core)
47+
RUN if [ -f composer.json ]; then composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader; fi \
48+
&& if [ -f core/composer.json ]; then cd core && composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader && cd - >/dev/null; fi
49+
50+
# Permissions (safe defaults; override in runtime if needed)
51+
RUN chown -R www-data:www-data storage core/storage assets \
52+
|| true
53+
54+
ENV APACHE_DOCUMENT_ROOT=/var/www/html
55+
56+
# Database environment variables
57+
ENV DB_CONNECTION=pgsql \
58+
DB_HOST=localhost \
59+
DB_PORT=5432 \
60+
DB_DATABASE=evolution \
61+
DB_USERNAME=evo \
62+
DB_PASSWORD=secret
63+
64+
# Evolution CMS installation variables
65+
ENV EVO_INSTALL_TYPE=1 \
66+
EVO_ADMIN_LOGIN=admin \
67+
EVO_ADMIN_EMAIL=admin@example.com \
68+
EVO_ADMIN_PASSWORD=admin123 \
69+
EVO_LANGUAGE=en \
70+
EVO_REMOVE_INSTALL=y \
71+
EVO_AUTO_INSTALL=true \
72+
EVO_TABLE_PREFIX=evo_ \
73+
EVO_MAIN_PACKAGE_NAME=main \
74+
EVO_INSTALL_TINYMCE=true
75+
76+
COPY docker/entrypoint.sh /entrypoint.sh
77+
RUN chmod +x /entrypoint.sh
78+
79+
EXPOSE 80
80+
ENTRYPOINT ["/entrypoint.sh"]
81+
CMD ["apache2-foreground"]
82+
83+

docker/entrypoint.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Runtime PHP configuration overrides
5+
if [ -n "$PHP_DISPLAY_ERRORS" ]; then
6+
if [ "$PHP_DISPLAY_ERRORS" = "1" ] || [ "$PHP_DISPLAY_ERRORS" = "On" ]; then
7+
echo "display_errors = On" > /usr/local/etc/php/conf.d/41-runtime.ini
8+
else
9+
echo "display_errors = Off" > /usr/local/etc/php/conf.d/41-runtime.ini
10+
fi
11+
fi
12+
13+
if [ -n "$PHP_MEMORY_LIMIT" ]; then
14+
echo "memory_limit = $PHP_MEMORY_LIMIT" >> /usr/local/etc/php/conf.d/41-runtime.ini
15+
fi
16+
17+
if [ -n "$PHP_MAX_EXECUTION_TIME" ]; then
18+
echo "max_execution_time = $PHP_MAX_EXECUTION_TIME" >> /usr/local/etc/php/conf.d/41-runtime.ini
19+
fi
20+
21+
# Ensure writable directories exist with correct permissions
22+
mkdir -p /var/www/html/core/storage/logs \
23+
/var/www/html/core/storage/cache \
24+
/var/www/html/core/storage/sessions \
25+
/var/www/html/storage \
26+
/var/www/html/assets/cache \
27+
/var/www/html/assets/export \
28+
/var/www/html/assets/files \
29+
/var/www/html/assets/images
30+
31+
# Set permissions for Evolution CMS directories
32+
chown -R www-data:www-data /var/www/html/core/storage || true
33+
chown -R www-data:www-data /var/www/html/storage || true
34+
chown -R www-data:www-data /var/www/html/assets || true
35+
36+
# Set proper file permissions (directories 755, files 644)
37+
find /var/www/html/core/storage -type d -exec chmod 755 {} \; || true
38+
find /var/www/html/core/storage -type f -exec chmod 644 {} \; || true
39+
find /var/www/html/assets -type d -exec chmod 755 {} \; || true
40+
find /var/www/html/assets -type f -exec chmod 644 {} \; || true
41+
42+
# Wait for database if DB_HOST is set
43+
if [ -n "$DB_HOST" ] && [ "$DB_HOST" != "localhost" ]; then
44+
echo "Waiting for database at $DB_HOST:${DB_PORT:-5432}..."
45+
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' "$DB_HOST" "${DB_PORT:-5432}" || echo "Database wait timeout"
46+
fi
47+
48+
# Auto-install Evolution CMS if not already installed
49+
if [ "$EVO_AUTO_INSTALL" = "true" ] && [ ! -f "/var/www/html/config.php" ]; then
50+
echo "🚀 Evolution CMS not found, starting auto-installation..."
51+
52+
# Check if install directory exists
53+
if [ -d "/var/www/html/install" ] && [ -f "/var/www/html/install/cli-install.php" ]; then
54+
echo "📦 Running Evolution CMS installation..."
55+
56+
cd /var/www/html/install/
57+
58+
# Map database type
59+
case "$DB_CONNECTION" in
60+
"pgsql"|"postgresql")
61+
DB_TYPE="postgresql"
62+
;;
63+
"mysql"|"mariadb")
64+
DB_TYPE="mysql"
65+
;;
66+
*)
67+
DB_TYPE="mysql"
68+
echo "⚠️ Unknown DB_CONNECTION '$DB_CONNECTION', defaulting to mysql"
69+
;;
70+
esac
71+
72+
# Run CLI installer
73+
php cli-install.php \
74+
--typeInstall="${EVO_INSTALL_TYPE}" \
75+
--databaseType="${DB_TYPE}" \
76+
--databaseServer="${DB_HOST}" \
77+
--databasePort="${DB_PORT}" \
78+
--database="${DB_DATABASE}" \
79+
--databaseUser="${DB_USERNAME}" \
80+
--databasePassword="${DB_PASSWORD}" \
81+
--tablePrefix="${EVO_TABLE_PREFIX:-evo_}" \
82+
--cmsAdmin="${EVO_ADMIN_LOGIN}" \
83+
--cmsAdminEmail="${EVO_ADMIN_EMAIL}" \
84+
--cmsPassword="${EVO_ADMIN_PASSWORD}" \
85+
--language="${EVO_LANGUAGE}" \
86+
--removeInstall="${EVO_REMOVE_INSTALL}"
87+
88+
if [ $? -eq 0 ]; then
89+
echo "✅ Evolution CMS installed successfully!"
90+
91+
# Post-installation setup
92+
cd /var/www/html/core/
93+
94+
# Create main package if MAIN_PACKAGE_NAME is set
95+
if [ -n "$EVO_MAIN_PACKAGE_NAME" ]; then
96+
echo "📦 Creating main package: $EVO_MAIN_PACKAGE_NAME"
97+
php artisan package:create "$EVO_MAIN_PACKAGE_NAME"
98+
echo "<?php return \"EvolutionCMS\\\\$EVO_MAIN_PACKAGE_NAME\\\\Controllers\\\\\"; ?>" > custom/config/cms/settings/ControllerNamespace.php
99+
fi
100+
101+
# Install TinyMCE5 if enabled
102+
if [ "$EVO_INSTALL_TINYMCE" = "true" ]; then
103+
echo "📝 Installing TinyMCE5..."
104+
php artisan extras extras TinyMCE5 master || echo "⚠️ TinyMCE5 installation failed"
105+
echo '<?php return "TinyMCE5"; ?>' > custom/config/cms/settings/which_editor.php || true
106+
fi
107+
108+
# Set final permissions
109+
cd /var/www/html/
110+
chown -R www-data:www-data . || true
111+
112+
echo "🎉 Evolution CMS setup completed!"
113+
else
114+
echo "❌ Evolution CMS installation failed!"
115+
exit 1
116+
fi
117+
else
118+
echo "❌ Install directory not found! Cannot auto-install."
119+
fi
120+
else
121+
if [ -f "/var/www/html/config.php" ]; then
122+
echo "✅ Evolution CMS already installed, skipping auto-install"
123+
fi
124+
fi
125+
126+
exec "$@"
127+
128+

docker/php.ini

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[PHP]
2+
; File uploads
3+
post_max_size = 100M
4+
upload_max_filesize = 100M
5+
max_file_uploads = 20
6+
7+
; Memory and execution
8+
memory_limit = 256M
9+
max_execution_time = 60
10+
max_input_time = 60
11+
12+
; Error handling
13+
display_errors = Off
14+
log_errors = On
15+
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
16+
17+
; Session
18+
session.cookie_httponly = On
19+
session.cookie_secure = Off
20+
session.use_strict_mode = 1
21+
22+
; Security
23+
expose_php = Off
24+
allow_url_fopen = On
25+
allow_url_include = Off
26+
27+
; Encoding
28+
default_charset = "UTF-8"
29+
variables_order = EGPCS
30+
date.timezone = UTC
31+
32+
; OPcache (production optimization)
33+
opcache.enable = 1
34+
opcache.memory_consumption = 128
35+
opcache.interned_strings_buffer = 8
36+
opcache.max_accelerated_files = 4000
37+
opcache.revalidate_freq = 60
38+
opcache.fast_shutdown = 1
39+
40+

0 commit comments

Comments
 (0)