fix: redesign
This commit is contained in:
+8
-6
@@ -1,9 +1,15 @@
|
|||||||
# Node modules and vendor directories
|
# Node modules and vendor directories
|
||||||
node_modules/
|
node_modules/
|
||||||
vendor/
|
|
||||||
|
# Ignore vendor only if dependencies are installed during the build
|
||||||
|
# Uncomment the next line if vendor is installed in the Dockerfile
|
||||||
|
# vendor/
|
||||||
|
|
||||||
# Environment files
|
# Environment files
|
||||||
.env.*
|
.env.local
|
||||||
|
.env.development
|
||||||
|
.env.production
|
||||||
|
.env.test
|
||||||
.env.example
|
.env.example
|
||||||
|
|
||||||
# Log files
|
# Log files
|
||||||
@@ -24,7 +30,6 @@ build/
|
|||||||
dist/
|
dist/
|
||||||
public/hot
|
public/hot
|
||||||
public/storage
|
public/storage
|
||||||
storage/*.key
|
|
||||||
storage/debugbar
|
storage/debugbar
|
||||||
storage/framework/cache/*
|
storage/framework/cache/*
|
||||||
storage/framework/sessions/*
|
storage/framework/sessions/*
|
||||||
@@ -50,7 +55,6 @@ coverage/
|
|||||||
|
|
||||||
# Docker-related files
|
# Docker-related files
|
||||||
.dockerignore
|
.dockerignore
|
||||||
docker-compose.yml
|
|
||||||
docker-compose.override.yml
|
docker-compose.override.yml
|
||||||
|
|
||||||
# CI/CD configuration files
|
# CI/CD configuration files
|
||||||
@@ -65,11 +69,9 @@ docker-compose.override.yml
|
|||||||
*.old
|
*.old
|
||||||
*.orig
|
*.orig
|
||||||
*.save
|
*.save
|
||||||
*.seed
|
|
||||||
*.cache
|
*.cache
|
||||||
*.pid
|
*.pid
|
||||||
*.seed
|
*.seed
|
||||||
*.log
|
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*.tmp
|
*.tmp
|
||||||
+52
-58
@@ -1,70 +1,64 @@
|
|||||||
# -------- 1) Composer deps (no scripts; avoids artisan during build) --------
|
# -------- Stage 1: Builder (Composer Dependencies) --------
|
||||||
FROM composer:2 AS vendor
|
FROM composer:2 AS vendor
|
||||||
ARG COMPOSER_NO_DEV=1
|
|
||||||
WORKDIR /app
|
|
||||||
COPY composer.json composer.lock ./
|
|
||||||
RUN if [ "$COMPOSER_NO_DEV" = "1" ]; then \
|
|
||||||
composer install --no-dev --prefer-dist --no-progress --no-interaction --classmap-authoritative --no-scripts; \
|
|
||||||
else \
|
|
||||||
composer install --prefer-dist --no-progress --no-interaction --classmap-authoritative --no-scripts; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -------- 2) App source --------
|
|
||||||
FROM alpine:3.22 AS app_src
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY composer.json composer.lock ./
|
||||||
|
|
||||||
|
RUN composer install --no-dev --optimize-autoloader --no-scripts --no-progress
|
||||||
|
|
||||||
|
# -------- Stage 2: Runtime (Alpine + PHP-FPM + Nginx + Supervisor) --------
|
||||||
|
FROM alpine:3.22
|
||||||
|
|
||||||
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Install system and PHP packages, inkl. SQLite & PostgreSQL
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
nginx supervisor gettext bash curl \
|
||||||
|
php82 php82-fpm php82-opcache php82-mbstring php82-xml php82-curl php82-zip \
|
||||||
|
php82-ctype php82-session php82-pdo php82-pdo_mysql php82-tokenizer php82-dom \
|
||||||
|
php82-fileinfo php82-gd php82-intl php82-simplexml php82-phar php82-bcmath \
|
||||||
|
php82-pdo_sqlite php82-sqlite3 php82-pgsql php82-pdo_pgsql \
|
||||||
|
nodejs npm
|
||||||
|
|
||||||
|
# Provide php alias
|
||||||
|
RUN ln -sf /usr/bin/php82 /usr/bin/php
|
||||||
|
|
||||||
|
# Create user, dirs, and sockets
|
||||||
|
RUN addgroup -S web && adduser -S web -G web \
|
||||||
|
&& mkdir -p /run/nginx /run/php /var/www/html /var/log/supervisor
|
||||||
|
|
||||||
|
# Configure PHP-FPM socket
|
||||||
|
RUN sed -i 's|^listen = 127\\.0\\.0\\.1:9000|listen = /run/php/php-fpm.sock|' /etc/php82/php-fpm.d/www.conf \
|
||||||
|
&& sed -i 's|^;listen.owner = nobody|listen.owner = nginx|' /etc/php82/php-fpm.d/www.conf \
|
||||||
|
&& sed -i 's|^;listen.group = nobody|listen.group = nginx|' /etc/php82/php-fpm.d/www.conf \
|
||||||
|
&& sed -i 's|^;listen.mode = 0660|listen.mode = 0660|' /etc/php82/php-fpm.d/www.conf \
|
||||||
|
&& sed -i 's|^user = nobody|user = nginx|' /etc/php82/php-fpm.d/www.conf \
|
||||||
|
&& sed -i 's|^group = nobody|group = nginx|' /etc/php82/php-fpm.d/www.conf
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
COPY --from=vendor /app/vendor ./vendor
|
||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
||||||
# -------- 3) Final: Nginx + PHP-FPM + PGSQL drivers --------
|
COPY deploy/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||||
FROM php:8.4-fpm-alpine
|
COPY deploy/supervisord.conf /etc/supervisor/supervisord.conf
|
||||||
|
COPY deploy/nginx/nginx.default.conf.template /etc/nginx/templates/default.conf.template
|
||||||
|
COPY deploy/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
# Build + runtime deps (incl. oniguruma for mbstring, GD runtime libs)
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
RUN set -eux; \
|
|
||||||
apk add --no-cache --virtual .build-deps \
|
|
||||||
$PHPIZE_DEPS icu-dev libzip-dev postgresql-dev \
|
|
||||||
freetype-dev libjpeg-turbo-dev libpng-dev \
|
|
||||||
oniguruma-dev pkgconf \
|
|
||||||
&& apk add --no-cache \
|
|
||||||
icu-libs libzip libpq tzdata bash git curl \
|
|
||||||
nginx supervisor \
|
|
||||||
oniguruma freetype libjpeg-turbo libpng \
|
|
||||||
&& docker-php-ext-configure intl \
|
|
||||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
||||||
&& docker-php-ext-install -j"$(nproc)" intl opcache zip bcmath mbstring gd pdo pdo_pgsql pgsql \
|
|
||||||
&& apk del .build-deps \
|
|
||||||
&& rm -rf /var/cache/apk/* /tmp/*
|
|
||||||
|
|
||||||
# PHP runtime tuning
|
# Permissions for Laravel writable directories
|
||||||
RUN set -eux; \
|
RUN mkdir -p storage bootstrap/cache \
|
||||||
{ \
|
&& chown -R nginx:nginx storage bootstrap/cache \
|
||||||
echo "memory_limit=512M"; \
|
&& chmod -R ug+rwX storage bootstrap/cache
|
||||||
echo "upload_max_filesize=64M"; \
|
|
||||||
echo "post_max_size=64M"; \
|
|
||||||
echo "max_execution_time=60"; \
|
|
||||||
} > /usr/local/etc/php/conf.d/laravel.ini
|
|
||||||
|
|
||||||
# Set timezone
|
# Build frontend assets
|
||||||
RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime
|
RUN npm ci && npm run build
|
||||||
|
|
||||||
# Copy application source
|
# Optimize Laravel configuration
|
||||||
WORKDIR /app
|
RUN php artisan config:cache && php artisan route:cache && php artisan view:cache && php artisan event:cache
|
||||||
COPY --from=app_src /app /app
|
|
||||||
COPY --from=vendor /app/vendor /app/vendor
|
|
||||||
|
|
||||||
# Set permissions for Laravel storage and cache
|
|
||||||
RUN set -eux; \
|
|
||||||
chown -R www-data:www-data /app/storage /app/bootstrap/cache /app/public; \
|
|
||||||
chmod -R 775 /app/storage /app/bootstrap/cache /app/public
|
|
||||||
|
|
||||||
# Configure Nginx
|
|
||||||
RUN mkdir -p /run/nginx
|
|
||||||
RUN mkdir -p /var/log/supervisor
|
|
||||||
COPY ./deploy/nginx/default.conf /etc/nginx/nginx.conf
|
|
||||||
|
|
||||||
# Configure Supervisor
|
|
||||||
COPY ./deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
|
||||||
|
|
||||||
# Expose ports
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
|
|
||||||
# Start Supervisor
|
|
||||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
SERVER_NAME="${SERVER_NAME:-$(hostname -f 2>/dev/null || hostname)}"
|
||||||
|
export SERVER_NAME
|
||||||
|
|
||||||
|
# Ensure dirs
|
||||||
|
mkdir -p /etc/nginx/http.d /etc/nginx/conf.d /run/nginx /run/php
|
||||||
|
|
||||||
|
# Render vhost ONLY into http.d so it's inside http{} context
|
||||||
|
if [ -f /etc/nginx/templates/default.conf.template ]; then
|
||||||
|
envsubst '$SERVER_NAME' < /etc/nginx/templates/default.conf.template > /etc/nginx/http.d/default.conf
|
||||||
|
else
|
||||||
|
echo "[entrypoint] ERROR: missing /etc/nginx/templates/default.conf.template" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[entrypoint] Using SERVER_NAME=$SERVER_NAME"
|
||||||
|
nginx -t || { echo "[entrypoint] nginx config test failed" >&2; cat /var/log/nginx/error.log || true; exit 1; }
|
||||||
|
|
||||||
|
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
|
||||||
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Default: DO NOT run artisan on boot (avoid provider issues)
|
|
||||||
: "${ARTISAN_BOOT:=0}"
|
|
||||||
: "${ARTISAN_DB_WAIT:=0}"
|
|
||||||
: "${ARTISAN_MIGRATE:=0}"
|
|
||||||
: "${ARTISAN_VERBOSE:=0}"
|
|
||||||
|
|
||||||
log() { [ "$ARTISAN_VERBOSE" = "1" ] && echo "[entrypoint] $*"; }
|
|
||||||
warn() { echo "[entrypoint] $*" 1>&2; }
|
|
||||||
|
|
||||||
cd /var/www/html || true
|
|
||||||
|
|
||||||
if [ "$ARTISAN_BOOT" != "1" ] || [ ! -f artisan ]; then
|
|
||||||
[ ! -f artisan ] && warn "artisan not found; skipping artisan."
|
|
||||||
exec /usr/bin/supervisord -c /etc/supervisord.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ARTISAN_DB_WAIT" = "1" ] && [ -n "$DB_HOST" ] && [ -n "$DB_PORT" ]; then
|
|
||||||
log "Waiting for DB ${DB_HOST}:${DB_PORT} ..."
|
|
||||||
i=0
|
|
||||||
until php -r '
|
|
||||||
$h=getenv("DB_HOST"); $p=(int)getenv("DB_PORT")?:5432;
|
|
||||||
$s=@fsockopen($h,$p,$errno,$errstr,1.0);
|
|
||||||
if($s){fclose($s); exit(0);} exit(1);
|
|
||||||
'; do
|
|
||||||
i=$((i+1)); [ $i -gt 60 ] && warn "DB wait timed out after 60s" && break
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if php artisan package:discover --ansi; then
|
|
||||||
php artisan config:cache --ansi || warn "config:cache failed"
|
|
||||||
php artisan route:cache --ansi || warn "route:cache failed"
|
|
||||||
php artisan view:cache --ansi || warn "view:cache failed"
|
|
||||||
else
|
|
||||||
warn "package:discover failed — skipping caches."
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ "$ARTISAN_MIGRATE" = "1" ] && php artisan migrate --force --no-interaction --ansi || true
|
|
||||||
|
|
||||||
exec /usr/bin/supervisord -c /etc/supervisord.conf
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 80 default_server;
|
|
||||||
server_name _;
|
|
||||||
|
|
||||||
root /var/www/html/public;
|
|
||||||
index index.php;
|
|
||||||
|
|
||||||
location = /healthz { return 200 "ok\n"; add_header Content-Type text/plain; }
|
|
||||||
|
|
||||||
location ~* \.(?:css|js|mjs|map|jpg|jpeg|png|gif|ico|svg|webp|avif|ttf|otf|woff|woff2)$ {
|
|
||||||
access_log off; log_not_found off;
|
|
||||||
expires 7d;
|
|
||||||
add_header Cache-Control "public, max-age=604800, immutable";
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.php?$query_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ \.php$ {
|
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
fastcgi_pass unix:/run/php/php-fpm.sock;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
|
||||||
fastcgi_param DOCUMENT_ROOT $realpath_root;
|
|
||||||
fastcgi_read_timeout 60s;
|
|
||||||
fastcgi_buffering on;
|
|
||||||
fastcgi_buffers 16 16k;
|
|
||||||
fastcgi_buffer_size 32k;
|
|
||||||
}
|
|
||||||
|
|
||||||
client_max_body_size 64m;
|
|
||||||
|
|
||||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
||||||
add_header X-Content-Type-Options "nosniff" always;
|
|
||||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
||||||
|
|
||||||
gzip on;
|
|
||||||
gzip_comp_level 5;
|
|
||||||
gzip_min_length 256;
|
|
||||||
gzip_proxied any;
|
|
||||||
gzip_types text/plain text/css application/json application/javascript application/xml+rss application/xml application/x-font-ttf font/opentype image/svg+xml;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
user nginx;
|
||||||
|
worker_processes auto;
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
|
||||||
|
access_log /dev/stdout main;
|
||||||
|
error_log /dev/stderr warn;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
# Server Blöcke sind NICHT hier!
|
||||||
|
# Stattdessen in:
|
||||||
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
include /etc/nginx/http.d/*.conf;
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name ${SERVER_NAME};
|
||||||
|
|
||||||
|
root /var/www/html/public;
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
# Cache-Control for static files
|
||||||
|
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff2?|eot|ttf|otf|webp|avif)$ {
|
||||||
|
expires 7d;
|
||||||
|
add_header Cache-Control "public, max-age=604800, immutable";
|
||||||
|
try_files $uri =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main application entry point
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
# PHP processing
|
||||||
|
location ~ \.php$ {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param DOCUMENT_ROOT $document_root;
|
||||||
|
fastcgi_read_timeout 60s;
|
||||||
|
fastcgi_buffering on;
|
||||||
|
fastcgi_buffers 16 16k;
|
||||||
|
fastcgi_buffer_size 32k;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Client upload size
|
||||||
|
client_max_body_size 64m;
|
||||||
|
|
||||||
|
# Security headers
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||||
|
|
||||||
|
# Gzip compression
|
||||||
|
gzip on;
|
||||||
|
gzip_comp_level 5;
|
||||||
|
gzip_min_length 256;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript application/xml+rss application/xml application/x-font-ttf font/opentype image/svg+xml application/vnd.ms-fontobject;
|
||||||
|
}
|
||||||
@@ -1,16 +1,3 @@
|
|||||||
[www]
|
listen = 127.0.0.1:9000
|
||||||
listen = /run/php/php-fpm.sock
|
user = nginx
|
||||||
listen.owner = www-data
|
group = nginx
|
||||||
listen.group = nginx
|
|
||||||
listen.mode = 0660
|
|
||||||
user = www-data
|
|
||||||
group = www-data
|
|
||||||
|
|
||||||
pm = dynamic
|
|
||||||
pm.max_children = 10
|
|
||||||
pm.start_servers = 2
|
|
||||||
pm.min_spare_servers = 2
|
|
||||||
pm.max_spare_servers = 5
|
|
||||||
|
|
||||||
clear_env = yes
|
|
||||||
env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
||||||
|
|||||||
+11
-8
@@ -1,23 +1,26 @@
|
|||||||
[supervisord]
|
[supervisord]
|
||||||
nodaemon=true
|
nodaemon=true
|
||||||
logfile=/var/log/supervisor/supervisord.log
|
logfile=/var/log/supervisor/supervisord.log
|
||||||
|
pidfile=/run/supervisord.pid
|
||||||
|
|
||||||
[program:php-fpm]
|
[program:php-fpm]
|
||||||
command=/usr/local/sbin/php-fpm -F
|
command=/usr/sbin/php-fpm82 -F
|
||||||
; run as root (master); FPM will drop to www-data for workers
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
|
startretries=3
|
||||||
priority=10
|
priority=10
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/fd/1
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/fd/2
|
||||||
stderr_logfile_maxbytes=0
|
stderr_logfile_maxbytes=0
|
||||||
|
|
||||||
[program:nginx]
|
[program:nginx]
|
||||||
command=/usr/sbin/nginx -g "daemon off;"
|
command=/usr/sbin/nginx -g 'daemon off;'
|
||||||
; run as root (master); nginx will use 'user nginx;' for workers
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
|
startretries=3
|
||||||
priority=20
|
priority=20
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/fd/1
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/fd/2
|
||||||
stderr_logfile_maxbytes=0
|
stderr_logfile_maxbytes=0
|
||||||
|
|||||||
Reference in New Issue
Block a user