V2
This commit is contained in:
1 parent
3883abbc85
commit
056f95384c
30 files changed
No files matched your search
@@ -1,140 +0,0 @@
|
||||
# Use PHP with Apache as the base image
|
||||
FROM php:8.4-apache
|
||||
|
||||
# Application root (default keeps the original /var/www/html layout)
|
||||
ENV APP_ROOT="/var/www/html"
|
||||
|
||||
# Environment
|
||||
ENV TZ="Europe/Prague" \
|
||||
APACHE_DOCUMENT_ROOT="${APP_ROOT}/public" \
|
||||
PHP_INI_FILE="$PHP_INI_DIR/php.ini" \
|
||||
PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
|
||||
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
|
||||
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
|
||||
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10" \
|
||||
COMPOSER_ALLOW_SUPERUSER=1
|
||||
|
||||
# Timezone
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# Install Additional System Dependencies
|
||||
RUN rm -f /etc/apt/apt.conf.d/docker-clean
|
||||
RUN --mount=type=cache,target=/var/cache/apt \
|
||||
apt-get update && apt-get install -yqq --no-install-recommends \
|
||||
git \
|
||||
libpq-dev \
|
||||
libzip-dev \
|
||||
zip \
|
||||
unzip \
|
||||
zlib1g-dev \
|
||||
libicu-dev \
|
||||
libjpeg-dev \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
libfreetype6-dev \
|
||||
g++ \
|
||||
nodejs \
|
||||
npm \
|
||||
cron \
|
||||
nano \
|
||||
default-mysql-client \
|
||||
postgresql-client \
|
||||
imagemagick \
|
||||
libmagickwand-dev \
|
||||
librsvg2-2 \
|
||||
librsvg2-dev \
|
||||
librsvg2-bin \
|
||||
supervisor && \
|
||||
git clone https://github.com/Imagick/imagick --depth 1 /tmp/imagick && \
|
||||
cd /tmp/imagick && \
|
||||
phpize && \
|
||||
./configure --with-rsvg && \
|
||||
ldconfig && \
|
||||
make && \
|
||||
make install && \
|
||||
apt-get autoremove && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
npm config set cache /tmp --global && \
|
||||
mkdir -p /var/log/supervisor
|
||||
|
||||
# Enable Apache mod_rewrite for URL rewriting
|
||||
RUN a2enmod rewrite
|
||||
|
||||
RUN docker-php-ext-configure intl
|
||||
|
||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp
|
||||
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-configure \
|
||||
opcache --enable-opcache
|
||||
|
||||
RUN docker-php-ext-install \
|
||||
pdo_mysql \
|
||||
pgsql \
|
||||
pdo_pgsql \
|
||||
zip \
|
||||
opcache \
|
||||
pcntl \
|
||||
sockets\
|
||||
bcmath \
|
||||
soap \
|
||||
gd \
|
||||
intl \
|
||||
calendar
|
||||
|
||||
RUN docker-php-ext-enable \
|
||||
imagick \
|
||||
opcache
|
||||
|
||||
# Fail fast if the JPEG delegate did not make it into the image
|
||||
RUN php -r 'if (!in_array("JPEG", Imagick::queryFormats())) { fwrite(STDERR, "ERROR: imagick built without JPEG delegate\n"); exit(1); } echo "imagick JPEG delegate OK\n";' && \
|
||||
php -r 'if (!function_exists("imagecreatefromjpeg")) { fwrite(STDERR, "ERROR: gd built without JPEG support\n"); exit(1); } echo "gd JPEG OK\n";'
|
||||
|
||||
# PHP
|
||||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \
|
||||
sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_FILE" && \
|
||||
sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_FILE" && \
|
||||
sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_FILE" && \
|
||||
printf '[Date]\ndate.timezone="%s"\n', $TZ > "$PHP_INI_DIR/conf.d/tzone.ini"
|
||||
|
||||
#OPCACHE
|
||||
RUN echo "\n\
|
||||
[opcache]\n\
|
||||
opcache.enable=1\n\
|
||||
opcache.revalidate_freq=0\n\
|
||||
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}\n\
|
||||
opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}\n\
|
||||
opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}\n\
|
||||
opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}\n\
|
||||
opcache.interned_strings_buffer=16\n\
|
||||
opcache.fast_shutdown=1" >> "$PHP_INI_DIR/conf.d/opcache.ini"
|
||||
|
||||
#SUPERVISORD
|
||||
RUN mkdir -p /var/log/supervisor
|
||||
COPY ./supervisor.d/ /etc/supervisor/conf.d/
|
||||
|
||||
#ENTRYPOINTS
|
||||
COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/
|
||||
COPY --chmod=755 ./entrypoint-runner.sh /usr/local/bin/entrypoint-runner.sh
|
||||
|
||||
# Persistent .env storage (see entrypoint.d/20-env.sh)
|
||||
RUN mkdir -p /config
|
||||
VOLUME /config
|
||||
|
||||
# Install composer # bun
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
# Configure Apache DocumentRoot to point to Laravel's public directory
|
||||
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
|
||||
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \
|
||||
sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \
|
||||
sed -i 's#^exec #entrypoint-runner.sh\n\nexec #' /usr/local/bin/apache2-foreground
|
||||
|
||||
#Cleaning
|
||||
RUN apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
rm -rf /var/cache/apt/* && \
|
||||
rm -rf /usr/share/man/* && \
|
||||
rm -rf /usr/share/doc/* && \
|
||||
rm -rf /tmp/*
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Legacy images ship their own start.sh in the app root and do the whole setup themselves.
|
||||
[ -f "${APP_ROOT:-/var/www/html}/start.sh" ] && exit 0
|
||||
|
||||
for f in /etc/entrypoint.d/*.sh; do
|
||||
if [ -x "$f" ]; then
|
||||
"$f" || { echo "entrypoint script failed: $f" >&2; exit 1; }
|
||||
fi
|
||||
done
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Mounted volumes are usually root-owned, so www-data could not write into storage and bootstrap/cache.
|
||||
cd "${APP_ROOT:-/var/www/html}" || exit 0
|
||||
|
||||
for dir in storage bootstrap/cache; do
|
||||
if [ -d "$dir" ] && [ "$(stat -c %U "$dir")" != "www-data" ]; then
|
||||
chown -R www-data:www-data "$dir"
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
for ini in "${PHP_INI_DIR}"/conf.d/*opcache.ini; do
|
||||
if [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "false" ]; then
|
||||
sed -ri -e "s!opcache.validate_timestamps=.*!opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}!g" "$ini"
|
||||
else
|
||||
sed -ri -e 's!opcache.enable=1!opcache.enable=0!g' "$ini"
|
||||
fi
|
||||
done
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Composer dependencies
|
||||
[ -f composer.json ] || exit 0
|
||||
|
||||
if [ "$init" = "true" ] || [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "true" ]; then
|
||||
echo "Initial setup nebo debug mód - instalace Composeru s dev závislostmi"
|
||||
composer install --prefer-dist --optimize-autoloader
|
||||
else
|
||||
echo "Produkční instalace - Composer bez dev závislostí"
|
||||
composer install --prefer-dist --no-dev --optimize-autoloader
|
||||
fi
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Prepares .env. When /config is mounted, .env is restored from /config/.env and saved there on first creation.
|
||||
cd "${APP_ROOT:-/var/www/html}" || exit 0
|
||||
|
||||
[ -f artisan ] || exit 0
|
||||
|
||||
if [ -d /config ] && [ -f /config/.env ]; then
|
||||
echo "Using existing /config/.env"
|
||||
cp /config/.env .env
|
||||
elif [ ! -f .env ] && [ -f .env.example ]; then
|
||||
echo "Creating .env from example"
|
||||
cp .env.example .env
|
||||
chown "$(stat -c %u:%g .env.example)" .env
|
||||
if [ -d /config ]; then
|
||||
cp .env /config/.env
|
||||
fi
|
||||
fi
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Generates APP_KEY only when none exists yet (env or .env), so an existing key is never rotated.
|
||||
cd "${APP_ROOT:-/var/www/html}" || exit 0
|
||||
|
||||
[ -f artisan ] || exit 0
|
||||
[ -f .env ] || exit 0
|
||||
[ -n "$APP_KEY" ] && exit 0
|
||||
|
||||
if ! grep -Eq '^APP_KEY=.+' .env; then
|
||||
echo "Generating application key"
|
||||
php artisan key:generate --force --no-interaction
|
||||
[ -d /config ] && cp .env /config/.env
|
||||
fi
|
||||
exit 0
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Clear Laravel caches
|
||||
[ -f artisan ] || exit 0
|
||||
|
||||
echo "Clearing Laravel caches"
|
||||
php artisan cache:clear
|
||||
php artisan config:clear
|
||||
php artisan route:clear
|
||||
php artisan view:clear
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SQLite database initialization
|
||||
if { grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; } || [ "$DEPLOY_ENV" = "sqlite" ]; then
|
||||
if [ ! -f database/database.sqlite ]; then
|
||||
echo "Creating empty SQLite database"
|
||||
touch database/database.sqlite
|
||||
fi
|
||||
fi
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Link storage and seed database if first init
|
||||
[ -f artisan ] || exit 0
|
||||
|
||||
echo "Linking storage directory"
|
||||
php artisan storage:link
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Migrate database
|
||||
[ -f artisan ] || exit 0
|
||||
|
||||
echo "Running database migrations"
|
||||
php artisan migrate --force --no-interaction
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
cat > /etc/supervisor/supervisord.conf <<'EOF'
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf
|
||||
EOF
|
||||
|
||||
# nodaemon=true keeps supervisord in the foreground, so detach it here
|
||||
supervisord -c /etc/supervisor/supervisord.conf &
|
||||
@@ -1,20 +0,0 @@
|
||||
[program:queue-default]
|
||||
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics
|
||||
user=www-data
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/queue-default.log
|
||||
|
||||
[program:queue-statistics]
|
||||
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=5 --tries=3 --queue=statistics
|
||||
user=www-data
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/queue-statistics.log
|
||||
|
||||
[program:queue-detections]
|
||||
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=detections
|
||||
user=www-data
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/queue-detections.log
|
||||
@@ -1,6 +0,0 @@
|
||||
[program:scheduler]
|
||||
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan schedule:work
|
||||
user=www-data
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/scheduler.log
|
||||
@@ -1,8 +0,0 @@
|
||||
; Example only, not loaded (supervisor includes just *.conf).
|
||||
; To enable it, copy it to /etc/supervisor/conf.d/reverb.conf (or rename it to reverb.conf in supervisor.d).
|
||||
[program:reverb]
|
||||
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan reverb:start --host=0.0.0.0 --no-interaction --debug
|
||||
user=www-data
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/reverb.log
|
||||
Reference in new issue
Block a user