File size: 1,324 Bytes
adead50
 
7b00edf
adead50
81a025a
 
 
adead50
81a025a
adead50
7b00edf
 
adead50
1e1a473
7b00edf
 
adead50
 
 
 
 
 
 
 
 
 
 
1e1a473
 
adead50
81a025a
adead50
 
 
 
81a025a
adead50
7b00edf
 
adead50
1e1a473
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 🐍 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"]