tasmimulhuda's picture
docker
1e7f09a
FROM python:3.10-slim
# Set environment variables to avoid caching issues
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
TRANSFORMERS_CACHE=/app/.hf_cache \
HF_HOME=/app/.hf_cache \
TORCH_HOME=/app/.hf_cache \
TMPDIR=/app/temp_files
# Set the working directory
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
ffmpeg \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create necessary directories with appropriate permissions
RUN mkdir -p /app/temp_files /app/.hf_cache && \
chmod -R 777 /app/temp_files /app/.hf_cache
# Copy requirement file and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# Ensure app folder and subfolders are fully accessible
RUN chmod -R 777 /app
# Expose the port that your Flask application will listen on.
# Hugging Face Spaces typically expects applications to listen on port 7860.
EXPOSE 7860
CMD ["python", "-m", "gunicorn", "-w", "1", "--bind", "0.0.0.0:7860", "app:app"]