FROM python:3.9-slim | |
# 2️⃣ Set working directory | |
WORKDIR /app | |
# 3️⃣ Install required system dependencies | |
RUN apt-get update && \ | |
apt-get install -y libgl1-mesa-glx libglib2.0-0 && \ | |
rm -rf /var/lib/apt/lists/* | |
# ⚡️ 3.1️⃣ Set environment variables for cache directories | |
ENV MPLCONFIGDIR=/tmp/.matplotlib | |
ENV TRANSFORMERS_CACHE=/tmp/.cache/huggingface | |
# ⚡️ 3.2️⃣ Create and set permission for cache directories | |
RUN mkdir -p /tmp/.matplotlib && chmod -R 777 /tmp/.matplotlib | |
RUN mkdir -p /tmp/.cache/huggingface && chmod -R 777 /tmp/.cache/huggingface | |
# 4️⃣ Copy requirements | |
COPY requirements.txt . | |
# 5️⃣ Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# 6️⃣ Copy all files from the root of your project | |
COPY . . | |
# 7️⃣ Expose the port | |
EXPOSE 7860 | |
# 8️⃣ Command to run the app | |
CMD ["python", "app.py"] | |