feat: Create a Docker Image around the laravel app
This commit is contained in:
1 parent
0bbb4571bd
commit
f978844e68
7 files changed
+287
No files matched your search
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cd /var/www/html || exit 1
|
||||
|
||||
# Ensure Laravel dirs exist (idempotent)
|
||||
mkdir -p storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache
|
||||
|
||||
# Fix perms (in case volumes are mounted)
|
||||
chown -R nginx:nginx storage bootstrap/cache || true
|
||||
chmod -R ug+rwX storage bootstrap/cache || true
|
||||
|
||||
# If Laravel present: clear stale build-stage caches pointing to /app, then warm new caches
|
||||
if [ -f artisan ]; then
|
||||
php artisan config:clear --no-ansi || true
|
||||
php artisan cache:clear --no-ansi || true
|
||||
php artisan route:clear --no-ansi || true
|
||||
php artisan view:clear --no-ansi || true
|
||||
# Optional: warm fresh caches in runtime path
|
||||
php artisan config:cache --no-ansi || true
|
||||
php artisan route:cache --no-ansi || true
|
||||
php artisan view:cache --no-ansi || true
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
PORT="${APP_PORT:-8080}"
|
||||
|
||||
# 1) App Health
|
||||
curl -fsS "http://127.0.0.1:${PORT}/healthz" >/dev/null
|
||||
|
||||
# 2) PHP-FPM Ping via Nginx
|
||||
curl -fsS "http://127.0.0.1:${PORT}/fpm-ping" >/dev/null
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,29 @@
|
||||
# keine 'user' Direktive im non-root Betrieb
|
||||
worker_processes auto;
|
||||
error_log /dev/stderr warn;
|
||||
pid /tmp/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;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
server_tokens off;
|
||||
|
||||
# Temp/Cache-Pfade, die 'nginx' gehören
|
||||
client_body_temp_path /var/lib/nginx/tmp/client_body 1 2;
|
||||
proxy_temp_path /var/lib/nginx/tmp/proxy 1 2;
|
||||
fastcgi_temp_path /var/lib/nginx/tmp/fastcgi 1 2;
|
||||
scgi_temp_path /var/lib/nginx/tmp/scgi 1 2;
|
||||
uwsgi_temp_path /var/lib/nginx/tmp/uwsgi 1 2;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
server {
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
|
||||
root /var/www/html/public;
|
||||
index index.php index.html;
|
||||
|
||||
# Readiness/Liveness
|
||||
location = /healthz { access_log off; return 200 "ok\n"; }
|
||||
|
||||
# FPM Ping/Status (optional absichern)
|
||||
location = /fpm-ping {
|
||||
access_log off;
|
||||
include fastcgi_params;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
fastcgi_param SCRIPT_NAME /ping;
|
||||
fastcgi_param PATH_INFO /ping;
|
||||
}
|
||||
location = /fpm-status {
|
||||
access_log off;
|
||||
include fastcgi_params;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
fastcgi_param SCRIPT_NAME /status;
|
||||
fastcgi_param PATH_INFO /status;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_read_timeout 60s;
|
||||
fastcgi_buffers 16 16k;
|
||||
}
|
||||
|
||||
location ~ /\.ht { deny all; }
|
||||
|
||||
# optionale Asset-Caches
|
||||
location ~* \.(?:css|js|jpg|jpeg|gif|png|svg|ico|webp|woff2?)$ {
|
||||
access_log off;
|
||||
expires 7d;
|
||||
add_header Cache-Control "public";
|
||||
try_files $uri =404;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/dev/fd/1
|
||||
logfile_maxbytes=0
|
||||
pidfile=/tmp/supervisord.pid
|
||||
childlogdir=/tmp
|
||||
|
||||
; one-shot init before services
|
||||
[program:init]
|
||||
command=/usr/local/bin/entrypoint.sh
|
||||
startsecs=0
|
||||
startretries=1
|
||||
autorestart=false
|
||||
priority=5
|
||||
stdout_logfile=/dev/fd/1
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/fd/2
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
[program:php-fpm]
|
||||
command=/usr/local/sbin/php-fpm -F
|
||||
priority=10
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stopsignal=QUIT
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
stdout_logfile=/dev/fd/1
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/fd/2
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
[program:nginx]
|
||||
command=/usr/sbin/nginx -g "daemon off;"
|
||||
priority=20
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stopsignal=QUIT
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
stdout_logfile=/dev/fd/1
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/fd/2
|
||||
stderr_logfile_maxbytes=0
|
||||
Reference in new issue
Block a user