FROM python:3.11-slim

ARG VOSK_DISABLE=false

WORKDIR /app

COPY requirements-web.txt .
RUN if [ "$VOSK_DISABLE" = "true" ]; then \
        grep -v '^vosk' requirements-web.txt > /tmp/requirements.txt && \
        pip install --no-cache-dir -r /tmp/requirements.txt; \
    else \
        pip install --no-cache-dir -r requirements-web.txt; \
    fi

COPY web_api.py .
COPY translations.json .
COPY Restore_Colorize.json .
COPY Change_2_Images_with_Res_1M_720p.json .
COPY Create_Image.json .
COPY prompts*.txt ./

RUN mkdir -p /app/output /app/uploads /app/logs /app/models /home/appuser/.cache/huggingface && \
    groupadd -g 1000 appuser && \
    useradd -u 1000 -g appuser -m appuser && \
    chown -R appuser:appuser /app /home/appuser/.cache

USER appuser

EXPOSE 8000

CMD ["python", "web_api.py"]
