advances / Dockerfile
OussamaElfila21's picture
Update Dockerfile
d232f13 verified
# 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"]