Merge pull request 'feat: Update Docker setup for refactored Flask architecture' (#2) from docker-refactor-updates into main

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2025-08-08 00:00:03 -04:00
5 changed files with 10 additions and 6 deletions

View File

@@ -32,7 +32,7 @@ RUN uv venv && \
ENV FLASK_APP=main.py ENV FLASK_APP=main.py
ENV FLASK_ENV=production ENV FLASK_ENV=production
ENV PATH="/app/.venv/bin:$PATH" ENV PATH="/app/.venv/bin:$PATH"
ENV GUNICORN_CMD_ARGS="--workers=4 --bind=0.0.0.0:5000 --timeout=120" ENV GUNICORN_CMD_ARGS="--workers=1 --bind=0.0.0.0:5000 --timeout=120"
# Expose port # Expose port
EXPOSE 5000 EXPOSE 5000

View File

@@ -15,7 +15,10 @@ def create_app():
app.config.from_object(Config) app.config.from_object(Config)
# Ensure upload directory exists # Ensure upload directory exists
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True) upload_path = os.path.join(app.static_folder, 'uploads')
os.makedirs(upload_path, exist_ok=True)
# Update config to use absolute path for file operations
app.config['UPLOAD_FOLDER'] = upload_path
# Setup logging # Setup logging
from app.utils.logging_config import setup_logging from app.utils.logging_config import setup_logging

View File

@@ -11,8 +11,8 @@ class Config:
# Flask settings # Flask settings
SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(24) SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(24)
# Upload settings # Upload settings
UPLOAD_FOLDER = os.environ.get('UPLOAD_FOLDER') or 'app/static/uploads' UPLOAD_FOLDER = os.environ.get('UPLOAD_FOLDER') or 'static/uploads'
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max file size MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max file size
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}

View File

@@ -9,7 +9,7 @@ services:
environment: environment:
- FLASK_APP=main.py - FLASK_APP=main.py
- FLASK_ENV=production - FLASK_ENV=production
- GUNICORN_CMD_ARGS=--workers=4 --bind=0.0.0.0:5000 --timeout=120 --keep-alive=5 --worker-class=sync --worker-connections=1000 --max-requests=1000 --max-requests-jitter=50 - GUNICORN_CMD_ARGS=--workers=1 --bind=0.0.0.0:5000 --timeout=120 --keep-alive=5 --worker-class=sync --worker-connections=1000 --max-requests=1000 --max-requests-jitter=50
# Application configuration # Application configuration
- UPLOAD_FOLDER=app/static/uploads - UPLOAD_FOLDER=app/static/uploads
- DATABASE_PATH=pet_pictures.db - DATABASE_PATH=pet_pictures.db

View File

@@ -15,4 +15,5 @@ app = create_app()
if __name__ == "__main__": if __name__ == "__main__":
# Development server configuration # Development server configuration
debug_mode = os.environ.get('FLASK_ENV') == 'development' debug_mode = os.environ.get('FLASK_ENV') == 'development'
app.run(debug=debug_mode, host='0.0.0.0', port=5000) port = int(os.environ.get('PORT', 5001)) # Use port 5001 to avoid AirPlay conflict
app.run(debug=debug_mode, host='0.0.0.0', port=port)