File size: 1,047 Bytes
55f48e7 8778088 a6a207b 55f48e7 | 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 | # Use an official Python runtime as the base image
FROM python:3.8-slim
# Prevent Python from writing .pyc files and buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set the working directory in the container
WORKDIR /app
# Create multiple cache directories and set proper permissions
RUN mkdir -p /app/cache && \
mkdir -p /tmp/cache && \
mkdir -p /.cache && \
chmod -R 777 /app/cache && \
chmod -R 777 /tmp/cache && \
chmod -R 777 /.cache
# Set environment variables for Hugging Face cache
ENV TRANSFORMERS_CACHE=/app/cache
ENV HF_HOME=/app/cache
ENV HUGGINGFACE_HUB_CACHE=/app/cache
# Copy over the requirements file first (for better Docker layer caching)
COPY requirements.txt /app/requirements.txt
# Install the Python dependencies
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r /app/requirements.txt
# Copy the rest of the application code
COPY . /app
# Expose the port that the app runs on
EXPOSE 7860
# Command to run the application
CMD ["python", "app.py"] |