Epharma / Dockerfile
Chaitanya895's picture
Update Dockerfile
827c087 verified
# Use the official Python slim image for a smaller footprint
FROM python:3.11-slim
# Set the working directory
WORKDIR /app
# Install system dependencies for psycopg2 and other potential native extensions
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
python3-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements file to leverage Docker cache
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the entire application code
COPY . .
# Ensure static files directory exists
RUN mkdir -p /app/static /app/templates
# Expose port 5000 (Render may override)
EXPOSE 5000
# Set environment variables for production
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1
ENV GUNICORN_CMD_ARGS="--workers=3 --timeout=120 --log-level=info"
# Command to run the application with gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
# Health check to ensure the app is responsive
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:5000/health || exit 1