# Use a slim Python image FROM python:3.9-slim # Set the working directory WORKDIR /app # Install system dependencies required for PyAudio, ffmpeg, and virtual audio devices RUN apt-get update && \ apt-get install -y \ python3-dev portaudio19-dev libportaudio2 \ alsa-utils alsa-oss alsa-tools pulseaudio \ build-essential gcc && \ rm -rf /var/lib/apt/lists/* # Set up a virtual audio device (for environments without physical audio hardware) RUN echo "pcm.!default { type hw card 0 }" > /etc/asound.conf && \ echo "ctl.!default { type hw card 0 }" >> /etc/asound.conf # Copy application files into the container COPY . . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Expose the necessary port EXPOSE 7860 # Set environment variable to ensure PyAudio works ENV PULSE_SERVER unix:/run/user/1000/pulse/native # Set the default command to run the application CMD ["python", "app.py"]