V2
This commit is contained in:
1 parent
3883abbc85
commit
056f95384c
30 files changed
No files matched your search
@@ -0,0 +1,121 @@
|
||||
FROM php:8.4-fpm-alpine
|
||||
|
||||
# Application root (same default as the apache image)
|
||||
ENV APP_ROOT="/var/www/html"
|
||||
|
||||
ENV TZ="Europe/Prague" \
|
||||
COMPOSER_ALLOW_SUPERUSER=1 \
|
||||
PHP_OPCACHE_ENABLE=1 \
|
||||
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
|
||||
PHP_OPCACHE_REVALIDATE_FREQ=0 \
|
||||
PHP_OPCACHE_MEMORY_CONSUMPTION=192 \
|
||||
PHP_OPCACHE_MAX_ACCELERATED_FILES=20000 \
|
||||
PHP_OPCACHE_MAX_WASTED_PERCENTAGE=10 \
|
||||
PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \
|
||||
APP_ENV=production \
|
||||
APP_DEBUG=false
|
||||
|
||||
RUN apk add --no-cache \
|
||||
tzdata \
|
||||
bash \
|
||||
ca-certificates \
|
||||
libpq \
|
||||
libzip \
|
||||
imagemagick \
|
||||
imagemagick-dev \
|
||||
librsvg \
|
||||
freetype \
|
||||
libjpeg-turbo \
|
||||
libpng \
|
||||
icu \
|
||||
oniguruma \
|
||||
libxml2 \
|
||||
libwebp \
|
||||
git \
|
||||
nano \
|
||||
zip \
|
||||
unzip \
|
||||
nodejs \
|
||||
npm \
|
||||
supervisor \
|
||||
mysql-client \
|
||||
postgresql-client
|
||||
|
||||
RUN apk add --no-cache --virtual .build-deps \
|
||||
$PHPIZE_DEPS \
|
||||
postgresql-dev \
|
||||
libzip-dev \
|
||||
freetype-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libwebp-dev \
|
||||
libpng-dev \
|
||||
icu-dev \
|
||||
libxml2-dev \
|
||||
linux-headers
|
||||
|
||||
RUN docker-php-ext-configure \
|
||||
gd --with-freetype --with-jpeg --with-webp \
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
pdo_mysql \
|
||||
pdo_pgsql \
|
||||
pgsql \
|
||||
zip \
|
||||
bcmath \
|
||||
soap \
|
||||
gd \
|
||||
intl \
|
||||
opcache \
|
||||
sockets \
|
||||
pcntl \
|
||||
calendar
|
||||
|
||||
RUN pecl install imagick \
|
||||
&& docker-php-ext-enable imagick
|
||||
|
||||
RUN apk del .build-deps
|
||||
|
||||
# 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";'
|
||||
|
||||
# Composer
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
|
||||
|
||||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
|
||||
&& echo "date.timezone=${TZ}" > "$PHP_INI_DIR/conf.d/99-timezone.ini"
|
||||
|
||||
RUN { \
|
||||
echo "memory_limit=256M"; \
|
||||
echo "upload_max_filesize=100M"; \
|
||||
echo "post_max_size=100M"; \
|
||||
echo "realpath_cache_size=4096K"; \
|
||||
echo "realpath_cache_ttl=600"; \
|
||||
} > "$PHP_INI_DIR/conf.d/99-laravel.ini"
|
||||
|
||||
RUN { \
|
||||
echo "[opcache]"; \
|
||||
echo "opcache.enable=${PHP_OPCACHE_ENABLE}"; \
|
||||
echo "opcache.enable_cli=0"; \
|
||||
echo "opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}"; \
|
||||
echo "opcache.revalidate_freq=${PHP_OPCACHE_REVALIDATE_FREQ}"; \
|
||||
echo "opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}"; \
|
||||
echo "opcache.interned_strings_buffer=${PHP_OPCACHE_INTERNED_STRINGS_BUFFER}"; \
|
||||
echo "opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}"; \
|
||||
echo "opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}"; \
|
||||
echo "opcache.save_comments=1"; \
|
||||
} > "$PHP_INI_DIR/conf.d/10-opcache.ini"
|
||||
|
||||
# Supervisor (queue workers + scheduler, started from entrypoint.d/90-supervisord.sh)
|
||||
RUN mkdir -p /var/log/supervisor
|
||||
COPY ./supervisor.d/ /etc/supervisor/conf.d/
|
||||
|
||||
# Entrypoint scripts (run in order from the stock entrypoint)
|
||||
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
|
||||
RUN sed -i 's#^exec #entrypoint-runner.sh\n\nexec #' /usr/local/bin/docker-php-entrypoint
|
||||
|
||||
WORKDIR ${APP_ROOT}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Link storage and seed database if first init
|
||||
[ -f artisan ] || exit 0
|
||||
|
||||
echo "Linking storage directory"
|
||||
php artisan storage:link
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Migrate database
|
||||
[ -f artisan ] || exit 0
|
||||
|
||||
echo "Running database migrations"
|
||||
php artisan migrate --force --no-interaction
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/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 &
|
||||
@@ -0,0 +1,20 @@
|
||||
[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
|
||||
@@ -0,0 +1,6 @@
|
||||
[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
|
||||
@@ -0,0 +1,8 @@
|
||||
; 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