v0.10.0: Docker + Update-Funktion + deploy.sh

This commit is contained in:
2026-07-02 21:14:18 +02:00
parent 85118c5bcc
commit af2aa1eaf5
20 changed files with 1169 additions and 11 deletions
+80
View File
@@ -0,0 +1,80 @@
#!/bin/bash
set -e
echo ""
echo "╔══════════════════════════════════════╗"
echo "║ Network-MGMT Startup ║"
echo "╚══════════════════════════════════════╝"
echo ""
cd /var/www/html
# ─── .env prüfen ───────────────────────────────────────────────────────────────
if [ ! -f ".env" ]; then
echo "⚠ .env fehlt — kopiere .env.example ..."
cp .env.example .env
fi
# ─── Auf Datenbank warten ──────────────────────────────────────────────────────
echo "▶ Warte auf MariaDB ..."
until php -r "
\$dsn = 'mysql:host=' . getenv('DB_HOST') . ';port=' . (getenv('DB_PORT') ?: 3306) . ';dbname=' . getenv('DB_DATABASE');
try {
new PDO(\$dsn, getenv('DB_USERNAME'), getenv('DB_PASSWORD'));
exit(0);
} catch (Exception \$e) {
exit(1);
}
" 2>/dev/null; do
echo " ... noch nicht bereit, warte 3s"
sleep 3
done
echo " ✓ Datenbank erreichbar"
# ─── Composer ──────────────────────────────────────────────────────────────────
if [ ! -d "vendor" ] || [ ! -f "vendor/autoload.php" ]; then
echo "▶ Composer: Abhängigkeiten installieren ..."
composer install --no-dev --optimize-autoloader --no-interaction --quiet
echo " ✓ fertig"
fi
# ─── Assets bauen ──────────────────────────────────────────────────────────────
if [ ! -d "public/build" ] && [ -f "package.json" ]; then
echo "▶ Node: Assets bauen ..."
npm ci --silent 2>/dev/null
npm run build 2>/dev/null
echo " ✓ fertig"
fi
# ─── App-Key ───────────────────────────────────────────────────────────────────
APP_KEY_VAL=$(grep "^APP_KEY=" .env | cut -d= -f2)
if [ -z "$APP_KEY_VAL" ] || [ "$APP_KEY_VAL" = "" ]; then
echo "▶ Generiere APP_KEY ..."
php artisan key:generate --no-interaction --force
fi
# ─── Storage-Link ──────────────────────────────────────────────────────────────
php artisan storage:link --no-interaction 2>/dev/null || true
# ─── Berechtigungen ────────────────────────────────────────────────────────────
chmod -R 775 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache 2>/dev/null || true
# ─── Migrationen ───────────────────────────────────────────────────────────────
echo "▶ Datenbank: Migrationen ausführen ..."
php artisan migrate --force --no-interaction
echo " ✓ fertig"
# ─── Cache ─────────────────────────────────────────────────────────────────────
echo "▶ Cache aufbauen ..."
php artisan config:cache --no-interaction 2>/dev/null
php artisan route:cache --no-interaction 2>/dev/null
php artisan view:cache --no-interaction 2>/dev/null
echo " ✓ fertig"
echo ""
echo "✓ Network-MGMT läuft auf Port 80"
echo ""
# ─── Supervisor starten (nginx + php-fpm + scheduler) ─────────────────────────
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
+43
View File
@@ -0,0 +1,43 @@
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# Datei-Upload bis 64 MB
client_max_body_size 64M;
server {
listen 80;
server_name _;
root /var/www/html/public;
index index.php;
# Laravel-Routen
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 120;
}
# Dotfiles sperren
location ~ /\.(?!well-known) {
deny all;
}
# Logs
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
}
+38
View File
@@ -0,0 +1,38 @@
[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
loglevel=info
; ─── PHP-FPM ───────────────────────────────────────────────────────────────────
[program:php-fpm]
command=php-fpm --nodaemonize --fpm-config /usr/local/etc/php-fpm.conf
autostart=true
autorestart=true
priority=10
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; ─── nginx ─────────────────────────────────────────────────────────────────────
[program:nginx]
command=nginx -g "daemon off;"
autostart=true
autorestart=true
priority=20
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; ─── Laravel Scheduler (jede Minute) ──────────────────────────────────────────
[program:scheduler]
command=bash -c "while true; do php /var/www/html/artisan schedule:run --no-ansi >> /proc/1/fd/1 2>&1; sleep 60; done"
autostart=true
autorestart=true
priority=30
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0