Spaces:
Running
Running
# Use an official Python runtime as a parent image | |
FROM python:3.9-slim | |
# Set environment variables for Hugging Face cache | |
ENV TRANSFORMERS_CACHE=/tmp/.cache | |
ENV HF_DATASETS_CACHE=/tmp/.cache | |
ENV TORCH_HOME=/tmp/.cache # Set PyTorch cache directory | |
# Create the cache directory and set permissions | |
RUN mkdir -p /tmp/.cache && chmod -R 777 /tmp/.cache | |
# Set the working directory in the container | |
WORKDIR /app | |
# Install system dependencies (required for soundfile and other libraries) | |
RUN apt-get update && apt-get install -y \ | |
libsndfile1 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy the requirements file into the container | |
COPY requirements.txt . | |
# Upgrade pip to the latest version | |
RUN pip install --upgrade pip | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the current directory contents into the container | |
COPY . . | |
# Expose port 7860 (default port for Gradio) | |
EXPOSE 7860 | |
# Run the app when the container launches | |
CMD ["python", "app.py"] |