mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
using 4 startup scripts instead of RC6
This commit is contained in:
@@ -1,24 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[ENTRYPOINT] Initializing container..."
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
# Run the main initialization script
|
||||
/app/dockerfiles/init.sh
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[ENTRYPOINT] Starting services..."
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
# Start all services in the background
|
||||
/app/dockerfiles/start-crond.sh &
|
||||
/app/dockerfiles/start-php-fpm.sh &
|
||||
/app/dockerfiles/start-nginx.sh &
|
||||
/app/dockerfiles/start-backend.sh &
|
||||
|
||||
# Wait for any process to exit
|
||||
wait -n
|
||||
|
||||
# Exit with status of process that exited first
|
||||
exit $?
|
||||
# Start all necessary services for NetAlertX
|
||||
/services/start-crond.sh &
|
||||
/services/start-php-fpm.sh &
|
||||
/services/start-nginx.sh &
|
||||
/services/start-backend.sh
|
||||
|
||||
@@ -3,4 +3,6 @@ echo "Initializing backend..."
|
||||
# Future backend initialization steps can go here.
|
||||
# For now, we'll just ensure permissions are correct.
|
||||
chown -R nginx:www-data "${NETALERTX_APP}"
|
||||
chmod 750 "${NETALERTX_APP}"/config "${NETALERTX_APP}"/log "${NETALERTX_APP}"/db
|
||||
find "${NETALERTX_APP}"/config "${NETALERTX_APP}"/log "${NETALERTX_APP}"/db -type f -exec chmod 640 {} \;
|
||||
echo "Backend initialized."
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
echo "Initializing crond..."
|
||||
# Add crontab file
|
||||
cp -f ${NETALERTX_APP}/install/crontab /etc/crontabs/root
|
||||
|
||||
chmod 600 /etc/crontabs/root
|
||||
chown root:root /etc/crontabs/root
|
||||
echo "crond initialized."
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
echo "Initializing nginx..."
|
||||
# Setup NGINX
|
||||
echo "Setting webserver to address ($LISTEN_ADDR) and port ($PORT)"
|
||||
envsubst '$NETALERTX_APP $LISTEN_ADDR $PORT' < "${NETALERTX_APP}/install/netalertx.template.conf" > "${NGINX_CONFIG_FILE}"
|
||||
envsubst '$NETALERTX_FRONT $LISTEN_ADDR $PORT' < "${NETALERTX_APP}/dockerfiles/netalertx.template.conf" > "${NGINX_CONFIG_FILE}"
|
||||
rm -f /etc/nginx/http.d/default.conf
|
||||
# Set nginx permissions
|
||||
chown nginx:nginx /run/nginx/ /var/log/nginx/ /var/lib/nginx/ /var/lib/nginx/tmp/
|
||||
chgrp www-data /var/www/localhost/htdocs/
|
||||
echo "nginx initialized."
|
||||
|
||||
62
dockerfiles/netalertx.template.conf
Executable file
62
dockerfiles/netalertx.template.conf
Executable file
@@ -0,0 +1,62 @@
|
||||
# map $request_uri $auth_result {
|
||||
# default "";
|
||||
# ~^/api/ /auth_result;
|
||||
# }
|
||||
|
||||
# log_format auth_request_log '$remote_addr - $remote_user [$time_local] '
|
||||
# '"$request" $status $body_bytes_sent '
|
||||
# '"$http_referer" "$http_user_agent" '
|
||||
# '$auth_result';
|
||||
|
||||
server {
|
||||
listen ${LISTEN_ADDR}:${PORT} default_server;
|
||||
root ${NETALERTX_FRONT};
|
||||
index index.php;
|
||||
add_header X-Forwarded-Prefix "/app" always;
|
||||
proxy_set_header X-Forwarded-Prefix "/app";
|
||||
|
||||
# # Authentication endpoint
|
||||
# location = /auth {
|
||||
# internal;
|
||||
# proxy_pass http://127.0.0.1/php/templates/auth.php;
|
||||
# proxy_set_header Content-Length "";
|
||||
# proxy_pass_request_body off;
|
||||
# }
|
||||
|
||||
# # Whitelisting IP addresses and CORS for /api/
|
||||
# location /api/ {
|
||||
# auth_request /auth;
|
||||
# access_log /var/log/nginx/auth_request.log auth_request_log;
|
||||
|
||||
# # Enable CORS for specific frontend domain
|
||||
# add_header 'Access-Control-Allow-Origin' 'http://192.168.1.82:20211' always;
|
||||
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||||
# add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
|
||||
# add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||||
|
||||
# if ($request_method = 'OPTIONS') {
|
||||
# return 204;
|
||||
# }
|
||||
|
||||
# error_page 401 = @unauthorized;
|
||||
|
||||
# # Other headers and configurations
|
||||
# try_files $uri $uri/ =404;
|
||||
# }
|
||||
|
||||
# location @unauthorized {
|
||||
# return 401;
|
||||
# }
|
||||
|
||||
location ~* \.php$ {
|
||||
# Set Cache-Control header to prevent caching on the first load
|
||||
add_header Cache-Control "no-store";
|
||||
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||
fastcgi_connect_timeout 75;
|
||||
fastcgi_send_timeout 600;
|
||||
fastcgi_read_timeout 600;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
#!/bin/bash
|
||||
echo "Starting backend..."
|
||||
cd "${NETALERTX_APP}" || exit
|
||||
# Clear previous logs
|
||||
echo '' > "${LOG_STDOUT}"
|
||||
echo '' > "${LOG_STDERR}"
|
||||
# Start the backend and redirect output
|
||||
exec python3 -m server >> "${LOG_STDOUT}" 2>> "${LOG_STDERR}"
|
||||
export PYTHONPATH="${NETALERTX_SERVER}"
|
||||
# Start the backend in the foreground, output will be handled by the container's logging driver
|
||||
python3 -m server
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo "Starting crond..."
|
||||
exec /usr/sbin/crond -f -L /dev/stdout
|
||||
exec /usr/sbin/crond -f -L "${LOG_EXECUTION_QUEUE}"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo "Starting nginx..."
|
||||
exec nginx -g "daemon off;"
|
||||
exec nginx -g "daemon off;" >> "${LOG_APP_FRONT}" 2>&1
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo "Starting php-fpm..."
|
||||
exec /usr/sbin/php-fpm83 -F
|
||||
exec /usr/sbin/php-fpm83 -F >> "${LOG_APP_PHP_ERRORS}" 2>&1
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script is now mostly handled by the Dockerfile
|
||||
# Only runtime cleanup remains
|
||||
|
||||
# Remove this script since all setup is now done at build time
|
||||
rm -f $0
|
||||
Reference in New Issue
Block a user