Files
Audio-Classifier/backend/Dockerfile
Benoit d5fda46eed Switch to Python 3.8 for Essentia compatibility
Essentia pre-built wheels are only available up to Python 3.8 (cp38)
Using essentia-2.1b6.dev218 for x86_64

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 23:33:21 +01:00

57 lines
1.5 KiB
Docker

FROM python:3.8-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
libsndfile1 \
libsndfile1-dev \
gcc \
g++ \
gfortran \
libopenblas-dev \
liblapack-dev \
pkg-config \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Upgrade pip, setuptools, wheel
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Copy requirements
COPY requirements.txt .
# Install Python dependencies in stages for better caching
RUN pip install --no-cache-dir numpy==1.24.3
RUN pip install --no-cache-dir scipy==1.11.4
# Install Essentia - Python 3.8 version (latest available with pre-built wheels)
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
echo "Installing Essentia for x86_64 Python 3.8..." && \
pip install --no-cache-dir --trusted-host essentia.upf.edu \
https://essentia.upf.edu/python-wheels/essentia-2.1b6.dev218-cp38-cp38-manylinux1_x86_64.whl || \
echo "Essentia installation failed, using fallback mode"; \
else \
echo "Essentia wheels only available for x86_64, using fallback mode"; \
fi
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY src/ ./src/
COPY alembic.ini .
COPY models/ ./models/
# Create models directory if not exists
RUN mkdir -p /app/models
# Expose port
EXPOSE 8000
# Run migrations and start server
CMD alembic upgrade head && \
uvicorn src.api.main:app --host 0.0.0.0 --port 8000