# Lightweight Python base image (no GPU/PyTorch needed)
FROM python:3.11-slim

# Labels
LABEL maintainer="Jacob Schmieder"
LABEL email="Jacob.Schmieder@dbfz.de"
LABEL version="0.1.1.dev"
LABEL description="Scraibe: LocalAI-backed transcription and diarization client with summarization and custom Web GUI. \
                    Sends audio to a LocalAI server running vibevoice.cpp and uses a second LLM for summarization."
LABEL url="https://git.optimex.systems/admin/scribe"

# Install system dependencies (ffmpeg, redis)
RUN apt update -y && \
    apt install -y --no-install-recommends ffmpeg redis-server && \
    apt clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Working directory
WORKDIR /app/src

# Environment variables for LocalAI (transcription/diarization)
ENV LOCALAI_API_URL=http://localhost:8080
ENV LOCALAI_API_KEY=
ENV LOCALAI_MODEL=vibevoice-cpp-asr

# Environment variables for Summarizer LLM
ENV SUMMARIZER_API_URL=http://localhost:8080
ENV SUMMARIZER_API_KEY=
ENV SUMMARIZER_MODEL=qwen3-14b

# Gradio / Web GUI
ENV GRADIO_SERVER_NAME=0.0.0.0

# Async processing (Celery + Redis)
ENV CELERY_BROKER_URL=redis://localhost:6379/0
ENV CELERY_RESULT_BACKEND=redis://localhost:6379/0
ENV SCRAIBE_UPLOAD_DIR=/tmp/scraibe_uploads

# Email and template configuration
ENV EMAIL_CONTACT_ADDRESS=support@example.com
ENV EMAIL_CSS_PATH=
ENV SCRAIBE_TEMPLATES_DIR=/app/src/misc
ENV SCRABIE_VERSION=0.1.1.dev

# Copy and install Python dependencies
COPY requirements.txt /app/src/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY scraibe /app/src/scraibe

# Copy custom Web GUI assets (header, footer, templates, logos, config)
COPY misc /app/src/misc

# Expose ports
EXPOSE 7860

# Run the Web GUI and Celery worker (with Redis) by default
CMD ["/bin/bash", "-c", "redis-server --daemonize yes && celery -A scraibe.celery_app worker -Q transcription -l info & python3 -m scraibe"]
