Solved other port bugs

This commit is contained in:
Kevin Veen-Birkenbach 2025-07-05 10:55:32 +02:00
parent 35bfeeb51e
commit 5fc19f6ccb
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
4 changed files with 9 additions and 13 deletions

View File

@ -11,11 +11,5 @@ RUN pip install --no-cache-dir -r requirements.txt
# Copy application code # Copy application code
COPY app/ . COPY app/ .
# Set default port environment variable
ENV PORT=5000
# Expose port (optional for documentation)
EXPOSE ${PORT}
# Start command using shell to allow env substitution # Start command using shell to allow env substitution
CMD ["sh", "-c", "exec python app.py --port=${PORT}"] CMD sh -c "exec python app.py --port=\${PORT}"

View File

@ -4,6 +4,12 @@ import yaml
from utils.configuration_resolver import ConfigurationResolver from utils.configuration_resolver import ConfigurationResolver
from utils.cache_manager import CacheManager from utils.cache_manager import CacheManager
from utils.compute_card_classes import compute_card_classes from utils.compute_card_classes import compute_card_classes
import logging
logging.basicConfig(level=logging.DEBUG)
FLASK_ENV = os.getenv("FLASK_ENV", "production")
FLASK_PORT = int(os.getenv("PORT", 5000))
print(f"🔧 Starting app on port {FLASK_PORT}, FLASK_ENV={FLASK_ENV}")
# Initialize the CacheManager # Initialize the CacheManager
cache_manager = CacheManager() cache_manager = CacheManager()
@ -31,9 +37,6 @@ def cache_icons_and_logos(app):
app.config["platform"]["favicon"]["cache"] = cache_manager.cache_file(app.config["platform"]["favicon"]["source"]) app.config["platform"]["favicon"]["cache"] = cache_manager.cache_file(app.config["platform"]["favicon"]["source"])
app.config["platform"]["logo"]["cache"] = cache_manager.cache_file(app.config["platform"]["logo"]["source"]) app.config["platform"]["logo"]["cache"] = cache_manager.cache_file(app.config["platform"]["logo"]["source"])
# Get the environment variable FLASK_ENV or set a default value
FLASK_ENV = os.getenv("FLASK_ENV", "production")
# Initialize Flask app # Initialize Flask app
app = Flask(__name__) app = Flask(__name__)
@ -64,5 +67,4 @@ def index():
) )
if __name__ == "__main__": if __name__ == "__main__":
port = int(os.getenv("PORT", 5000)) app.run(debug=(FLASK_ENV == "development"), host="0.0.0.0", port=FLASK_PORT)
app.run(debug=(FLASK_ENV == "development"), host="0.0.0.0", port=port)

View File

@ -11,6 +11,7 @@ services:
- "${PORT:-5000}:${PORT:-5000}" - "${PORT:-5000}:${PORT:-5000}"
volumes: volumes:
- ./app:/app - ./app:/app
- ./.env:/app./.env
environment: environment:
- PORT=${PORT:-5000} - PORT=${PORT:-5000}
restart: unless-stopped restart: unless-stopped

View File

@ -25,7 +25,6 @@ import os
from dotenv import load_dotenv from dotenv import load_dotenv
from pathlib import Path from pathlib import Path
# Always load .env from the script's directory
dotenv_path = Path(__file__).resolve().parent / ".env" dotenv_path = Path(__file__).resolve().parent / ".env"
if dotenv_path.exists(): if dotenv_path.exists():