Spaces:
Running
Running
Soumik Bose commited on
Commit ·
c7980ff
1
Parent(s): adff313
ok whatever
Browse files- Dockerfile +14 -29
- requirements.txt +2 -0
Dockerfile
CHANGED
|
@@ -1,46 +1,31 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
RUN apt-get update && apt-get install -y
|
| 9 |
-
|
| 10 |
-
g++ \
|
| 11 |
-
cmake \
|
| 12 |
-
git \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
-
# Create
|
| 16 |
RUN useradd -m -u 1000 user
|
| 17 |
-
RUN chown -R user:user /app
|
| 18 |
|
| 19 |
USER user
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
ENV PATH="/home/user/.local/bin:${PATH}" \
|
| 23 |
-
PYTHONDONTWRITEBYTECODE=1 \
|
| 24 |
-
PYTHONUNBUFFERED=1 \
|
| 25 |
-
PORT=7860 \
|
| 26 |
-
HF_HOME=/app/cache
|
| 27 |
-
|
| 28 |
-
# Upgrade pip
|
| 29 |
RUN pip install --no-cache-dir --upgrade pip
|
| 30 |
-
|
| 31 |
-
# Install llama-cpp-python (this will build it)
|
| 32 |
-
RUN CMAKE_ARGS="-DGGML_BLAS=OFF -DGGML_NATIVE=OFF" \
|
| 33 |
-
pip install --no-cache-dir llama-cpp-python==0.3.2
|
| 34 |
-
|
| 35 |
-
# Copy and install other requirements
|
| 36 |
COPY --chown=user:user requirements.txt .
|
| 37 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 38 |
|
| 39 |
-
# Copy
|
| 40 |
COPY --chown=user:user main.py .
|
| 41 |
|
| 42 |
-
# Expose port
|
| 43 |
EXPOSE 7860
|
| 44 |
-
|
| 45 |
-
# Run the application
|
| 46 |
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 4 |
+
PYTHONUNBUFFERED=1 \
|
| 5 |
+
PORT=7860 \
|
| 6 |
+
HF_HOME=/app/cache \
|
| 7 |
+
PATH="/home/user/.local/bin:${PATH}"
|
| 8 |
|
|
|
|
| 9 |
WORKDIR /app
|
| 10 |
|
| 11 |
+
# Minimal dependencies
|
| 12 |
+
RUN apt-get update && apt-get install -y \
|
| 13 |
+
curl \
|
|
|
|
|
|
|
|
|
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
+
# Create user
|
| 17 |
RUN useradd -m -u 1000 user
|
| 18 |
+
RUN mkdir -p /app/cache /app/models && chown -R user:user /app
|
| 19 |
|
| 20 |
USER user
|
| 21 |
|
| 22 |
+
# Install everything
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
RUN pip install --no-cache-dir --upgrade pip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
COPY --chown=user:user requirements.txt .
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
+
# Copy app
|
| 28 |
COPY --chown=user:user main.py .
|
| 29 |
|
|
|
|
| 30 |
EXPOSE 7860
|
|
|
|
|
|
|
| 31 |
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
requirements.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
fastapi>=0.115.0
|
| 2 |
uvicorn>=0.30.0
|
| 3 |
pydantic>=2.8.0
|
|
|
|
| 1 |
+
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
|
| 2 |
+
llama-cpp-python>=0.2.90
|
| 3 |
fastapi>=0.115.0
|
| 4 |
uvicorn>=0.30.0
|
| 5 |
pydantic>=2.8.0
|