From f1332e00e1314a483d696edae2cedc3734658868 Mon Sep 17 00:00:00 2001 From: Marius Robert Macamete Date: Wed, 10 Sep 2025 15:16:39 +0300 Subject: [PATCH] add dockerfile --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ requirements.txt | 3 ++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8024f24 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Use a lightweight Python base +FROM python:3.12-slim + +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +# Set work directory +WORKDIR /app + +# Install system dependencies (if needed for pip packages) +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Copy requirements first (for caching) +COPY requirements.txt /app/ + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the app +COPY . /app/ + +# Expose Flask port +EXPOSE 5000 + +# Default env vars (can override at runtime) +ENV FLASK_APP=app:create_app +ENV FLASK_RUN_HOST=0.0.0.0 +ENV FLASK_RUN_PORT=5000 +ENV FLASK_ENV=production + +# Start Flask with Gunicorn (better for prod than flask run) +CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:create_app()"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b2e4076..b7fbc2d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Flask==3.0.3 -python-dotenv==1.0.1 \ No newline at end of file +python-dotenv==1.0.1 +gunicorn==22.0.0 \ No newline at end of file