From 8270c7ccd045942f837ea80aedb8ffb2f5cb66e1 Mon Sep 17 00:00:00 2001 From: greirson Date: Tue, 6 May 2025 20:07:02 -0700 Subject: [PATCH] feat(docker): Added a health check endpoint to ensure the application is running properly, enhancing reliability in deployment. --- docker-compose.yml | 11 ++++++++--- src/app.js | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 957b851..3621834 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,13 +14,18 @@ services: DUMBDROP_PIN: 123456 # Optional PIN protection (4-10 digits, leave empty to disable) AUTO_UPLOAD: true # Upload without clicking button BASE_URL: http://localhost:3000 # The base URL for the application - + # Additional available environment variables (commented out with defaults) # FOOTER_LINKS: "My Site @ https://example.com,Docs @ https://docs.example.com" # Custom footer links # PORT: 3000 # Server port (default: 3000) # NODE_ENV: production # Node environment (development/production) - # DEBUG: false # Debug mode for verbose logging (default: false in production, true in development) # APPRISE_URL: "" # Apprise notification URL for upload notifications (default: none) # APPRISE_MESSAGE: "New file uploaded - {filename} ({size}), Storage used {storage}" # Notification message template with placeholders: {filename}, {size}, {storage} # APPRISE_SIZE_UNIT: "Auto" # Size unit for notifications (B, KB, MB, GB, TB, or Auto) - # ALLOWED_EXTENSIONS: ".jpg,.jpeg,.png,.pdf,.doc,.docx,.txt" # Comma-separated list of allowed file extensions (default: all allowed) \ No newline at end of file + # ALLOWED_EXTENSIONS: ".jpg,.jpeg,.png,.pdf,.doc,.docx,.txt" # Comma-separated list of allowed file extensions (default: all allowed) + # healthcheck: + # test: ["CMD", "curl", "--fail", "http://localhost:3000/health"] + # interval: 30s + # timeout: 10s + # retries: 3 + # start_period: 30s \ No newline at end of file diff --git a/src/app.js b/src/app.js index 4801c7e..97349d9 100644 --- a/src/app.js +++ b/src/app.js @@ -136,6 +136,11 @@ app.get('/login.html', (req, res) => { } }); +// --- Health Check Endpoint --- +app.get('/health', (req, res) => { + res.status(200).json({ status: 'UP', message: 'Server is healthy' }); +}); + // --- Static File Serving --- // Serve static files (CSS, JS, assets) from the 'public' directory // Use express.static middleware, placed AFTER specific HTML routes