Spaces:
Running
Running
File size: 1,916 Bytes
25e6afd 45e9602 25e6afd 45e9602 25e6afd 45e9602 25e6afd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # Base image
FROM python:3.11-slim
# Prevent Python from writing .pyc files and buffer stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
SDL_AUDIODRIVER=dummy
# System deps for OpenCV, audio (PyAudio/portaudio), and general build
# - libgl1, libglib2.0-0: needed by opencv-python
# - ffmpeg: media processing (optional but useful)
# - build-essential, portaudio19-dev, libasound2-dev: to compile PyAudio
# - libportaudio2, libportaudiocpp0: runtime for PyAudio
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ffmpeg \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libportaudio2 \
libportaudiocpp0 \
libasound2 \
portaudio19-dev \
libasound2-dev \
espeak-ng \
libespeak1 \
&& rm -rf /var/lib/apt/lists/*
# Create working directory
WORKDIR /app
# Install Python dependencies first (leverage Docker layer cache)
COPY requirements.txt ./
RUN pip install --upgrade pip \
&& pip install -r requirements.txt
# Optional: remove build toolchain and -dev packages to reduce final image size
# Keep runtime libs like libportaudio2 installed
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get purge -y \
build-essential \
portaudio19-dev \
libasound2-dev \
&& DEBIAN_FRONTEND=noninteractive apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
# Copy the application code
COPY backend ./backend
COPY frontend ./frontend
COPY server.py ./server.py
# Expose FastAPI port
EXPOSE 7860
# Default environment variables (can be overridden at runtime)
# Example:
# ENV RAPIDAPI_HOST=real-time-image-search.p.rapidapi.com
# ENV AI_MODEL_URL=http://host.docker.internal:12345/v1/chat/completions
# Start the server using uvicorn directly (avoids reload in production)
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
|