# Use a specific version for better stability FROM python:3.10-alpine # 1. Install EVERY build dependency needed for a C++ compile on Alpine # we add linux-headers and python3-dev to prevent "missing header" errors RUN apk add --no-cache \ build-base \ cmake \ musl-dev \ python3-dev \ linux-headers \ libc6-compat \ libstdc++ \ libgomp \ openblas-dev \ libgcc RUN adduser -D -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # 2. Tell the compiler to use Alpine's math libraries ENV CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" # 3. Install packages # WARNING: This will take 15 minutes. The logs will look "stuck". # DO NOT REBOOT. Let it finish the "Building wheel" stage. RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir flask flask-cors huggingface-hub && \ pip install --no-cache-dir llama-cpp-python COPY --chown=user . $HOME/app EXPOSE 7860 CMD ["python", "app.py"]