API / Dockerfile
Tmeena's picture
Update Dockerfile
72ce43f verified
raw
history blame
1.31 kB
# Use an official Python runtime as a parent image
FROM python:3.8-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Set environment variables for Hugging Face cache and Whisper model
ENV HF_HOME=/app/cache
ENV TRANSFORMERS_CACHE=/app/cache
# Install the required dependencies (including gevent)
RUN pip install --no-cache-dir -r requirements.txt
# Install ffmpeg for audio processing
RUN apt-get update && apt-get install -y ffmpeg
# Create cache and temp directories with appropriate permissions
RUN mkdir -p /app/cache /app/temp && chmod -R 777 /app/cache /app/temp
# Pre-download the Whisper and M2M100 models to avoid download issues at runtime
RUN python -c "from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer; \
M2M100ForConditionalGeneration.from_pretrained('facebook/m2m100_418M', cache_dir='/app/cache'); \
M2M100Tokenizer.from_pretrained('facebook/m2m100_418M', cache_dir='/app/cache')" && \
python -c "import whisper; whisper.load_model('turbo', download_root='/app/cache')"
# Expose the necessary port (same as in the Flask app)
EXPOSE 7860
# Start the app using Gunicorn with gevent workers for handling concurrency
CMD ["python","app.py"]