FROM python:3.10-slim

ENV FLASK_APP=src/app.py
ARG PIP_REQ_FILE=requirements.txt

WORKDIR /app

RUN apt update && apt install git ffmpeg -y && \
    pip3 install "git+https://github.com/openai/whisper.git"

RUN whisper --model medium --language ru dummy.wav; exit 0 && \
    whisper --model small --language ru dummy.wav; exit 0

COPY src/ src/

# Separate requirements installation to keep other dependencies
# in cache
COPY ${PIP_REQ_FILE} ${PIP_REQ_FILE}
RUN pip3 install -r ${PIP_REQ_FILE}

EXPOSE 5000

CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]