feat: add debug entrypoint script and enhance health check logging
Build And Push Image / docker (push) Successful in 2m33s Details

This commit is contained in:
Matt 2025-08-07 02:56:53 +02:00
parent 378e730c68
commit d8420b8f9e
4 changed files with 150 additions and 3 deletions

View File

@ -18,11 +18,16 @@ FROM base as production
ENV PORT=$PORT
COPY --from=build /app/.output /app/.output
# Copy debug entrypoint script
COPY docker-entrypoint-debug.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint-debug.sh
# Add health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:6060/api/health || exit 1
# Install curl for health check
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Install curl and net-tools for health check and debugging
RUN apt-get update && apt-get install -y curl net-tools wget && rm -rf /var/lib/apt/lists/*
CMD ["node", ".output/server/index.mjs"]
# Use debug entrypoint
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-debug.sh"]

114
docker-entrypoint-debug.sh Normal file
View File

@ -0,0 +1,114 @@
#!/bin/sh
set -e
echo "=== MonacoUSA Portal Debug Startup ==="
echo "Timestamp: $(date)"
echo "Node Version: $(node --version)"
echo "NPM Version: $(npm --version)"
echo "Working Directory: $(pwd)"
echo "User: $(whoami)"
echo "UID: $(id -u)"
echo "GID: $(id -g)"
echo ""
echo "=== Environment Variables ==="
echo "NODE_ENV: $NODE_ENV"
echo "NUXT_HOST: $NUXT_HOST"
echo "NUXT_PORT: $NUXT_PORT"
echo "NITRO_HOST: $NITRO_HOST"
echo "NITRO_PORT: $NITRO_PORT"
# Check if Keycloak variables are set
if [ -n "$NUXT_KEYCLOAK_ISSUER" ]; then
echo "NUXT_KEYCLOAK_ISSUER: $NUXT_KEYCLOAK_ISSUER"
echo "NUXT_KEYCLOAK_CLIENT_ID: $NUXT_KEYCLOAK_CLIENT_ID"
echo "NUXT_KEYCLOAK_CLIENT_SECRET: [SET]"
echo "NUXT_KEYCLOAK_CALLBACK_URL: $NUXT_KEYCLOAK_CALLBACK_URL"
else
echo "⚠️ Keycloak variables not set"
fi
# Check if NocoDB variables are set
if [ -n "$NUXT_NOCODB_URL" ]; then
echo "NUXT_NOCODB_URL: $NUXT_NOCODB_URL"
echo "NUXT_NOCODB_TOKEN: [SET]"
echo "NUXT_NOCODB_BASE_ID: $NUXT_NOCODB_BASE_ID"
else
echo "⚠️ NocoDB variables not set"
fi
# Check session secrets
if [ -n "$NUXT_SESSION_SECRET" ]; then
echo "NUXT_SESSION_SECRET: [SET - ${#NUXT_SESSION_SECRET} chars]"
else
echo "❌ NUXT_SESSION_SECRET: NOT SET"
fi
if [ -n "$NUXT_ENCRYPTION_KEY" ]; then
echo "NUXT_ENCRYPTION_KEY: [SET - ${#NUXT_ENCRYPTION_KEY} chars]"
else
echo "❌ NUXT_ENCRYPTION_KEY: NOT SET"
fi
echo ""
echo "=== File System Check ==="
echo "Contents of /app:"
ls -la /app/
if [ -d "/app/.output" ]; then
echo ""
echo "Contents of /app/.output:"
ls -la /app/.output/
if [ -f "/app/.output/server/index.mjs" ]; then
echo "✅ Server file exists: /app/.output/server/index.mjs"
echo "Server file size: $(stat -c%s /app/.output/server/index.mjs) bytes"
else
echo "❌ Server file missing: /app/.output/server/index.mjs"
fi
else
echo "❌ .output directory missing!"
fi
echo ""
echo "=== Network Check ==="
echo "Checking if port $NUXT_PORT is available..."
if netstat -tuln | grep ":$NUXT_PORT "; then
echo "⚠️ Port $NUXT_PORT is already in use"
else
echo "✅ Port $NUXT_PORT is available"
fi
echo ""
echo "=== Service Connectivity Check ==="
# Test Keycloak connectivity
if [ -n "$NUXT_KEYCLOAK_ISSUER" ]; then
echo "Testing Keycloak connectivity..."
if wget -q --spider --timeout=10 "$NUXT_KEYCLOAK_ISSUER" 2>/dev/null; then
echo "✅ Keycloak is reachable: $NUXT_KEYCLOAK_ISSUER"
else
echo "❌ Keycloak is NOT reachable: $NUXT_KEYCLOAK_ISSUER"
fi
fi
# Test NocoDB connectivity
if [ -n "$NUXT_NOCODB_URL" ]; then
echo "Testing NocoDB connectivity..."
if wget -q --spider --timeout=10 "$NUXT_NOCODB_URL" 2>/dev/null; then
echo "✅ NocoDB is reachable: $NUXT_NOCODB_URL"
else
echo "❌ NocoDB is NOT reachable: $NUXT_NOCODB_URL"
fi
fi
echo ""
echo "=== Starting Application ==="
echo "Command: node .output/server/index.mjs"
echo "Starting at: $(date)"
# Set Node.js to output logs immediately
export NODE_OPTIONS="--max-old-space-size=8192 --trace-warnings"
# Start the application with verbose logging
exec node .output/server/index.mjs

View File

@ -2,6 +2,18 @@ export default defineNuxtConfig({
ssr: false,
compatibilityDate: "2024-11-01",
devtools: { enabled: true },
// Add startup logging
hooks: {
'ready': () => {
console.log('🚀 MonacoUSA Portal Nuxt is ready!')
console.log('Environment:', process.env.NODE_ENV)
console.log('Port:', process.env.NUXT_PORT || process.env.PORT || 3000)
},
'listen': (server, { host, port }) => {
console.log(`🌐 Server listening on http://${host}:${port}`)
}
},
modules: ["vuetify-nuxt-module", "@vite-pwa/nuxt", "motion-v/nuxt"],
app: {
head: {

View File

@ -1,12 +1,25 @@
export default defineEventHandler(async (event) => {
console.log('🏥 Health check requested at:', new Date().toISOString());
try {
const config = useRuntimeConfig();
// Basic health check - can be expanded to check database, storage, etc.
const health = {
status: 'healthy',
timestamp: new Date().toISOString(),
uptime: process.uptime(),
version: process.version,
environment: process.env.NODE_ENV,
port: process.env.NUXT_PORT || process.env.PORT || 6060,
checks: {
server: 'healthy',
config: {
keycloak: !!config.keycloak?.issuer,
nocodb: !!config.nocodb?.url,
session: !!config.sessionSecret,
encryption: !!config.encryptionKey,
},
// Add more checks as needed
// database: await checkDatabase(),
// storage: await checkStorage(),
@ -14,8 +27,11 @@ export default defineEventHandler(async (event) => {
},
};
console.log('✅ Health check passed:', health.status);
return health;
} catch (error) {
console.error('❌ Health check failed:', error);
throw createError({
statusCode: 503,
statusMessage: 'Service Unavailable',