Add flexible Flask port configuration via environment variable
- 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 <noreply@anthropic.com>
This commit is contained in:
1
.env
1
.env
@@ -1,4 +1,5 @@
|
|||||||
# WOL Manager Environment Configuration
|
# WOL Manager Environment Configuration
|
||||||
WOL_NETWORK_MODE=bridge
|
WOL_NETWORK_MODE=bridge
|
||||||
WOL_EXTERNAL_PORT=5000
|
WOL_EXTERNAL_PORT=5000
|
||||||
|
FLASK_PORT=5000
|
||||||
FLASK_DEBUG=true
|
FLASK_DEBUG=true
|
||||||
@@ -10,6 +10,9 @@ WOL_NETWORK_MODE=bridge
|
|||||||
# For Linux with host mode: this setting is ignored
|
# For Linux with host mode: this setting is ignored
|
||||||
WOL_EXTERNAL_PORT=5000
|
WOL_EXTERNAL_PORT=5000
|
||||||
|
|
||||||
|
# Flask internal port (port on which Flask app runs inside container)
|
||||||
|
FLASK_PORT=5000
|
||||||
|
|
||||||
# Examples:
|
# Examples:
|
||||||
# Windows Docker Desktop:
|
# Windows Docker Desktop:
|
||||||
# WOL_NETWORK_MODE=bridge
|
# WOL_NETWORK_MODE=bridge
|
||||||
|
|||||||
@@ -485,5 +485,7 @@ def trigger_windows_scan():
|
|||||||
})
|
})
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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
|
# Enable debug mode for development with hot reload
|
||||||
app.run(host='0.0.0.0', port=5000, debug=True, use_reloader=True)
|
app.run(host='0.0.0.0', port=port, debug=True, use_reloader=True)
|
||||||
@@ -15,6 +15,7 @@ services:
|
|||||||
- PYTHONUNBUFFERED=1
|
- PYTHONUNBUFFERED=1
|
||||||
- WSL_INTEROP=${WSL_INTEROP}
|
- WSL_INTEROP=${WSL_INTEROP}
|
||||||
- FLASK_DEBUG=${FLASK_DEBUG:-false}
|
- FLASK_DEBUG=${FLASK_DEBUG:-false}
|
||||||
|
- FLASK_PORT=${FLASK_PORT:-5000}
|
||||||
network_mode: "${WOL_NETWORK_MODE:-bridge}"
|
network_mode: "${WOL_NETWORK_MODE:-bridge}"
|
||||||
privileged: true
|
privileged: true
|
||||||
cap_add:
|
cap_add:
|
||||||
|
|||||||
Reference in New Issue
Block a user