Ravi / Dockerfile
starkbyte45896's picture
Update Dockerfile
adead50 verified
Raw History Blame Contribute Delete
1.32 kB
# 🐍 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"]