FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04

WORKDIR /app

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y python3 python3-pip git wget

COPY requirements.txt /app/
RUN pip3 install --no-cache-dir -r requirements.txt
RUN pip3 install vllm

COPY . /app/

ENV PYTHONUNBUFFERED=1
ENV CUDA_VISIBLE_DEVICES=all

RUN mkdir -p /root/.cache/huggingface/hub
RUN git lfs install
RUN python3 -c "from transformers import AutoTokenizer, AutoModelForCausalLM; model_name='deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct'; AutoTokenizer.from_pretrained(model_name); AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)"

CMD ["python3", "scripts/run_inference.py"]