Chorus-Detection / Dockerfile
dennisvdang's picture
Refactor code and remove unnecessary files
606184e
FROM python:3.9-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH="${PYTHONPATH}:/app:/home/user/app:."
ENV MODEL_REVISION="20e66eb3d0788373c3bdc5b28fa2f2587b0e475f3bbc47e8ab9ff0dbdbb2df32"
ENV MODEL_HF_REPO="dennisvdang/chorus-detection"
ENV HF_MODEL_FILENAME="chorus_detection_crnn.h5"
# Set work directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt
# Copy app files
COPY . .
# Install package in development mode
RUN pip install -e .
# Make the entry point script executable
RUN chmod +x .space/app-entrypoint.sh || echo "Could not chmod app-entrypoint.sh"
# Verify chorus_detection package installation
RUN cd /app && \
python -c "import chorus_detection; print(f'Successfully imported chorus_detection')" || \
echo "Warning: chorus_detection module not properly installed"
# Ensure model exists
RUN python -c "from download_model import ensure_model_exists; ensure_model_exists(revision='${MODEL_REVISION}')" || \
echo "Warning: Model download failed during build"
# Expose port for Streamlit
EXPOSE 7860
# Run the app
CMD ["bash", "-c", "cd /app && ./.space/app-entrypoint.sh"]