feat: setup Docker production stack, Vite asset compilation, and resolve audit findings (P1/P2)
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "Starting RKM Laravel Application Container..."
|
||||
|
||||
# Wait for MySQL to be ready if DB_CONNECTION is mysql
|
||||
if [ "$DB_CONNECTION" = "mysql" ]; then
|
||||
echo "Waiting for MySQL database at $DB_HOST:$DB_PORT..."
|
||||
while ! nc -z "$DB_HOST" "$DB_PORT"; do
|
||||
sleep 1
|
||||
done
|
||||
echo "MySQL database is reachable!"
|
||||
fi
|
||||
|
||||
# Ensure storage directories exist and have proper permissions
|
||||
mkdir -p /var/www/storage/framework/cache/data \
|
||||
/var/www/storage/framework/sessions \
|
||||
/var/www/storage/framework/views \
|
||||
/var/www/storage/logs \
|
||||
/var/www/bootstrap/cache
|
||||
|
||||
chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache
|
||||
chmod -R 775 /var/www/storage /var/www/bootstrap/cache
|
||||
|
||||
# Run database migrations
|
||||
echo "Executing database migrations..."
|
||||
php artisan migrate --force
|
||||
|
||||
# Seed database if explicitly requested
|
||||
if [ "$RUN_SEEDER" = "true" ]; then
|
||||
echo "Seeding database..."
|
||||
php artisan db:seed --force
|
||||
fi
|
||||
|
||||
# Ensure symbolic link for storage
|
||||
php artisan storage:link || true
|
||||
|
||||
# Production optimization caches
|
||||
if [ "$APP_ENV" = "production" ]; then
|
||||
echo "Caching configuration, routes, and views for production..."
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
else
|
||||
echo "Clearing caches for non-production environment..."
|
||||
php artisan config:clear
|
||||
php artisan route:clear
|
||||
php artisan view:clear
|
||||
fi
|
||||
|
||||
echo "RKM Laravel is ready! Starting PHP-FPM..."
|
||||
exec "$@"
|
||||
@@ -0,0 +1,53 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
client_max_body_size 40M;
|
||||
|
||||
# Security Headers
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
# Gzip Compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# Static Assets Caching
|
||||
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv|svgz?|ttf|ttc|otf|eot|woff2?)$ {
|
||||
expires 1y;
|
||||
access_log off;
|
||||
add_header Cache-Control "public, no-transform, immutable";
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
error_page 404 /index.php;
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass app:9000;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
fastcgi_hide_header X-Powered-By;
|
||||
fastcgi_buffers 16 16k;
|
||||
fastcgi_buffer_size 32k;
|
||||
fastcgi_read_timeout 300;
|
||||
}
|
||||
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
upload_max_filesize = 40M
|
||||
post_max_size = 40M
|
||||
memory_limit = 512M
|
||||
max_execution_time = 300
|
||||
max_input_time = 300
|
||||
date.timezone = Asia/Jakarta
|
||||
expose_php = Off
|
||||
@@ -0,0 +1,10 @@
|
||||
[opcache]
|
||||
opcache.enable = 1
|
||||
opcache.enable_cli = 1
|
||||
opcache.memory_consumption = 128
|
||||
opcache.interned_strings_buffer = 16
|
||||
opcache.max_accelerated_files = 10000
|
||||
opcache.revalidate_freq = 0
|
||||
opcache.validate_timestamps = 0
|
||||
opcache.save_comments = 1
|
||||
opcache.fast_shutdown = 1
|
||||
Reference in New Issue
Block a user