From 59e905162cb49bf64da5247b08e85078289e9ffa Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Fri, 13 Jun 2025 16:58:30 -0400 Subject: [PATCH] feat: switch to Gunicorn for production --- Dockerfile | 5 +++-- docker-compose.yml | 1 + pyproject.toml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d897d14..ce05a39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,9 +30,10 @@ RUN uv venv && \ ENV FLASK_APP=main.py ENV FLASK_ENV=production ENV PATH="/app/.venv/bin:$PATH" +ENV GUNICORN_CMD_ARGS="--workers=4 --bind=0.0.0.0:5000 --timeout=120" # Expose port EXPOSE 5000 -# Run the application -CMD ["python", "main.py"] \ No newline at end of file +# Run the application with Gunicorn +CMD ["gunicorn", "main:app"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 760a5c1..96c912a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: environment: - FLASK_APP=main.py - FLASK_ENV=production + - GUNICORN_CMD_ARGS=--workers=4 --bind=0.0.0.0:5000 --timeout=120 restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:5000"] diff --git a/pyproject.toml b/pyproject.toml index 2f6b8d7..d8e6583 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ dependencies = [ "flask>=3.0.0", "werkzeug>=3.0.0", "python-dotenv>=1.0.0", + "gunicorn>=21.2.0", ] [build-system]