# 🐍 Use an official lightweight Python image FROM python:3.10-slim as builder # 📌 Install system dependencies (OpenSSL for TLS & CA Certificates) RUN apt-get update && apt-get install -y \ libssl-dev \ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Clean up package lists # 📂 Set the working directory inside the container WORKDIR /app # 📦 Copy and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 🏗 Final Production Image FROM python:3.10-slim # 📂 Set the working directory inside the container WORKDIR /app # 🔁 Copy installed dependencies from builder stage COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages COPY --from=builder /usr/local/bin /usr/local/bin # 🗂 Copy the entire application code into the container COPY . . # 🔐 Set secure environment variables (MongoDB URI) ENV PYTHONUNBUFFERED=1 ENV MONGO_USER="Ravi" ENV MONGO_PASS="Aditya@2006@#" ENV MONGO_CLUSTER="ravi.btpy9.mongodb.net" ENV MONGO_URI="mongodb+srv://${MONGO_USER}:${MONGO_PASS}@${MONGO_CLUSTER}/?retryWrites=true&w=majority&tls=true" # 🚪 Expose Flask application port EXPOSE 7860 # 🚀 Start the Flask app with Gunicorn (4 workers) CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:app"]