monolithic alpine container

This commit is contained in:
Adam Outler
2025-09-25 07:43:42 -04:00
parent 2e694a752d
commit 8ed21a8c07
24 changed files with 204 additions and 978 deletions

View File

@@ -0,0 +1,73 @@
#!/bin/bash
# NetAlertX Comprehensive Health Check Script
# This script verifies all critical services and endpoints are functioning
set -e
EXIT_CODE=0
echo "[HEALTHCHECK] Starting comprehensive health check..."
# Function to log errors and set exit code
log_error() {
echo "[HEALTHCHECK] ERROR: $1" >&2
EXIT_CODE=1
}
# Function to log success
log_success() {
echo "[HEALTHCHECK] ✓ $1"
}
# 1. Check if crond is running
if pgrep -f "crond" > /dev/null; then
log_success "crond is running"
else
log_error "crond is not running"
fi
# 2. Check if php-fpm is running
if pgrep -f "php-fpm" > /dev/null; then
log_success "php-fpm is running"
else
log_error "php-fpm is not running"
fi
# 3. Check if nginx is running
if pgrep -f "nginx" > /dev/null; then
log_success "nginx is running"
else
log_error "nginx is not running"
fi
# 4. Check if python /app/server is running
if pgrep -f "python.*server" > /dev/null; then
log_success "python /app/server is running"
else
log_error "python /app/server is not running"
fi
# 5. Check port 20211 is open and contains "netalertx"
if curl -sf --max-time 10 "http://localhost:${PORT:-20211}" | grep -i "netalertx" > /dev/null; then
log_success "Port ${PORT:-20211} is responding and contains 'netalertx'"
else
log_error "Port ${PORT:-20211} is not responding or doesn't contain 'netalertx'"
fi
# 6. Check port 20212/graphql returns "graphql" in first lines
GRAPHQL_PORT=${GRAPHQL_PORT:-20212}
if curl -sf --max-time 10 "http://localhost:${GRAPHQL_PORT}/graphql" | head -10 | grep -i "graphql" > /dev/null; then
log_success "Port ${GRAPHQL_PORT}/graphql is responding with GraphQL content"
else
log_error "Port ${GRAPHQL_PORT}/graphql is not responding or doesn't contain 'graphql'"
fi
# Summary
if [ $EXIT_CODE -eq 0 ]; then
echo "[HEALTHCHECK] ✅ All health checks passed"
else
echo "[HEALTHCHECK] ❌ One or more health checks failed"
fi
exit $EXIT_CODE

View File

@@ -0,0 +1,6 @@
#!/bin/bash
echo "Starting backend..."
cd "${NETALERTX_APP}" || exit
export PYTHONPATH="${NETALERTX_SERVER}"
# Start the backend, teeing stdout and stderr to log files and the container's console
python3 -m server > >(tee /app/log/stdout.log) 2> >(tee /app/log/stderr.log >&2)

View File

@@ -0,0 +1,3 @@
#!/bin/bash
echo "Starting crond..."
exec /usr/sbin/crond -f -L "${LOG_CROND}"

View File

@@ -0,0 +1,5 @@
#!/bin/bash
echo "Starting nginx..."
exec nginx \
-c "${NGINX_CONFIG_FILE}" \
-g "daemon off;" >> "${LOG_APP_FRONT}" 2>&1

View File

@@ -0,0 +1,3 @@
#!/bin/bash
echo "Starting php-fpm..."
exec /usr/sbin/php-fpm83 -F >> "${LOG_APP_PHP_ERRORS}" 2>&1