|
|
|
FROM python:3.10-slim |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
build-essential \ |
|
cmake \ |
|
wget \ |
|
curl \ |
|
git \ |
|
git-lfs \ |
|
pkg-config \ |
|
libopenblas-dev \ |
|
libssl-dev \ |
|
musl-dev \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
RUN git lfs install |
|
|
|
|
|
ENV PYTHONUNBUFFERED=1 |
|
ENV PYTHONDONTWRITEBYTECODE=1 |
|
ENV PIP_NO_CACHE_DIR=1 |
|
ENV CMAKE_ARGS="-DLLAMA_OPENBLAS=on" |
|
ENV FORCE_CMAKE=1 |
|
ENV DOCKER_CONTAINER=true |
|
|
|
|
|
RUN mkdir -p /app/models |
|
|
|
|
|
RUN ln -sf /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 || \ |
|
ln -sf /usr/lib/x86_64-linux-gnu/libc.so.6 /lib/libc.musl-x86_64.so.1 |
|
|
|
|
|
COPY requirements.txt . |
|
|
|
|
|
RUN pip install --no-cache-dir -r requirements.txt |
|
|
|
|
|
COPY config.py . |
|
|
|
|
|
RUN python -c "import os; from huggingface_hub import hf_hub_download; from config import Config; os.makedirs('/app/models', exist_ok=True); print(f'Downloading model {Config.MODEL_REPO}/{Config.MODEL_FILENAME}...'); p=hf_hub_download(repo_id=Config.MODEL_REPO, filename=Config.MODEL_FILENAME, local_dir='/app/models', token=os.getenv('HUGGINGFACE_TOKEN') or None); print(f'Model downloaded to: {p}'); import os; s=os.path.getsize(p) if os.path.exists(p) else (_ for _ in ()).throw(FileNotFoundError(f'Model file not found: {p}')); print(f'Model file size: {s/(1024**3):.2f} GB'); (s>1024*1024) or (_ for _ in ()).throw(ValueError(f'Downloaded model file seems too small: {s} bytes')); print('Model download verification successful')" |
|
|
|
|
|
RUN ls -la /app/models/ && \ |
|
[ -f "/app/models/gemma-3n-E4B-it-Q8_0.gguf" ] || (echo "Model file not found!" && exit 1) |
|
|
|
|
|
COPY . . |
|
|
|
|
|
RUN chmod +x entrypoint.sh |
|
|
|
|
|
RUN useradd -m -u 1000 user && chown -R user:user /app |
|
USER user |
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
ENTRYPOINT ["./entrypoint.sh"] |
|
CMD ["python", "main.py", "--mode", "gradio"] |
|
|