Spaces:
Sleeping
Sleeping
File size: 1,265 Bytes
5d92054 7b7ac20 5d92054 6af86f9 d232f13 6af86f9 5d92054 7b7ac20 5d92054 6af86f9 7b7ac20 e1b1b87 |
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 43 44 45 46 47 48 |
# Use a specific Python version
FROM python:3.11.10-slim
# Set the working directory inside the container
WORKDIR /usr/src/app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libgl1-mesa-glx \
libglib2.0-0 \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Create cache directories with proper permissions
RUN mkdir -p /app_cache/huggingface && \
mkdir -p /app_cache/matplotlib && \
chmod -R 777 /app_cache
# Set environment variables to use custom cache locations
ENV TRANSFORMERS_CACHE=/app_cache/huggingface
ENV HF_HOME=/app_cache/huggingface
ENV MPLCONFIGDIR=/app_cache/matplotlib
ENV TORCH_HOME=/app_cache/torch
# Upgrade pip
RUN pip install --upgrade pip
# Install Python dependencies
COPY requirements.txt .
RUN pip install -r requirements.txt
# Copy your application code into the container
COPY . .
# Build Cython extensions
RUN cd utils && python setup.py build_ext --inplace
# Create necessary directories if they don't exist
RUN mkdir -p data/models && \
chmod -R 777 data
# Expose the port for FastAPI application
EXPOSE 7860
# Specify the command to run the application with uvicorn directly
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |