From 86931a091e934bcd1f0f7ad8816e39606409b448 Mon Sep 17 00:00:00 2001 From: Marius Mutu Date: Sat, 6 Sep 2025 23:14:24 +0300 Subject: [PATCH] Add flexible Flask port configuration via environment variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add FLASK_PORT environment variable support in docker-compose.yml - Update Flask app to read port from FLASK_PORT environment variable - Add FLASK_PORT configuration to .env and .env.example files - Enables running Flask on custom ports to avoid port conflicts in containerized environments 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .env | 1 + .env.example | 3 +++ app/app.py | 4 +++- docker-compose.yml | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.env b/.env index b15941c..7e803d0 100644 --- a/.env +++ b/.env @@ -1,4 +1,5 @@ # WOL Manager Environment Configuration WOL_NETWORK_MODE=bridge WOL_EXTERNAL_PORT=5000 +FLASK_PORT=5000 FLASK_DEBUG=true \ No newline at end of file diff --git a/.env.example b/.env.example index 1f4b346..f0c3727 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,9 @@ WOL_NETWORK_MODE=bridge # For Linux with host mode: this setting is ignored WOL_EXTERNAL_PORT=5000 +# Flask internal port (port on which Flask app runs inside container) +FLASK_PORT=5000 + # Examples: # Windows Docker Desktop: # WOL_NETWORK_MODE=bridge diff --git a/app/app.py b/app/app.py index dbad33b..5f0e4a1 100644 --- a/app/app.py +++ b/app/app.py @@ -485,5 +485,7 @@ def trigger_windows_scan(): }) if __name__ == '__main__': + # Get port from environment variable or default to 5000 + port = int(os.environ.get('FLASK_PORT', 5000)) # Enable debug mode for development with hot reload - app.run(host='0.0.0.0', port=5000, debug=True, use_reloader=True) \ No newline at end of file + app.run(host='0.0.0.0', port=port, debug=True, use_reloader=True) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 27a7b9f..a2c68d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: - PYTHONUNBUFFERED=1 - WSL_INTEROP=${WSL_INTEROP} - FLASK_DEBUG=${FLASK_DEBUG:-false} + - FLASK_PORT=${FLASK_PORT:-5000} network_mode: "${WOL_NETWORK_MODE:-bridge}" privileged: true cap_add: