Spaces:
Running
Running
| # 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"] | |