30 lines
No EOL
690 B
Docker
30 lines
No EOL
690 B
Docker
# Use an official Python runtime as a base
|
|
FROM python:3.11-slim-bookworm
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
build-essential \
|
|
libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first to leverage Docker cache
|
|
COPY requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Environment variables
|
|
ENV FLASK_APP=app.py
|
|
ENV FLASK_ENV=production
|
|
ENV ENVIRONMENT=production
|
|
|
|
EXPOSE 5001
|
|
|
|
# Use Gunicorn as production server
|
|
CMD ["gunicorn", "--bind", "0.0.0.0:5001", "--workers", "4", "--timeout", "120", "app:app"] |