Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +17 -19
Dockerfile
CHANGED
|
@@ -1,41 +1,39 @@
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
-
# 1.
|
| 4 |
ENV PYTHONUNBUFFERED=1
|
| 5 |
|
| 6 |
-
# 2. SYSTEM DEPENDENCIES
|
| 7 |
-
#
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
git \
|
| 10 |
build-essential \
|
| 11 |
cmake \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
-
# 3. SETUP USER 1000 (
|
| 15 |
-
# We create the user
|
| 16 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
USER user
|
| 18 |
ENV HOME=/home/user \
|
| 19 |
PATH=/home/user/.local/bin:$PATH
|
| 20 |
|
| 21 |
-
|
| 22 |
-
# Set the working directory to the user's home so they have write permissions
|
| 23 |
-
WORKDIR $HOME/app
|
| 24 |
-
|
| 25 |
-
# 5. INSTALL LLAMA-CPP-PYTHON
|
| 26 |
-
# compiling this takes time, so we do it before copying code to cache the layer
|
| 27 |
-
ENV CMAKE_ARGS="-DLLAMA_NATIVE=OFF"
|
| 28 |
-
ENV FORCE_CMAKE=1
|
| 29 |
-
RUN pip install --no-cache-dir llama-cpp-python==0.2.90
|
| 30 |
|
| 31 |
-
# 6. INSTALL REQUIREMENTS
|
| 32 |
-
# Copy only requirements first to leverage Docker caching
|
| 33 |
COPY --chown=user requirements.txt .
|
| 34 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 35 |
|
| 36 |
-
# 7. COPY APP CODE
|
| 37 |
-
# Important: use --chown=user so the user can read/execute the files
|
| 38 |
COPY --chown=user . .
|
| 39 |
|
| 40 |
-
# 8. LAUNCH
|
| 41 |
CMD ["python", "app.py"]
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
+
# 1. CONFIG: Fix the "Silence" by forcing logs to print immediately
|
| 4 |
ENV PYTHONUNBUFFERED=1
|
| 5 |
|
| 6 |
+
# 2. SYSTEM DEPENDENCIES (Run as root)
|
| 7 |
+
# We install these first so they are cached
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
git \
|
| 10 |
build-essential \
|
| 11 |
cmake \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
+
# 3. SETUP USER 1000 (Required for HF Spaces)
|
| 15 |
+
# We create the user now but switch to them later
|
| 16 |
RUN useradd -m -u 1000 user
|
| 17 |
+
|
| 18 |
+
# 4. INSTALL LLAMA-CPP-PYTHON (Your Build Configuration)
|
| 19 |
+
# Note: FORCE_CMAKE=1 triggers a compilation from source, which takes time.
|
| 20 |
+
ENV CMAKE_ARGS="-DLLAMA_NATIVE=OFF"
|
| 21 |
+
ENV FORCE_CMAKE=1
|
| 22 |
+
|
| 23 |
+
RUN pip install --no-cache-dir \
|
| 24 |
+
llama-cpp-python==0.2.90
|
| 25 |
+
|
| 26 |
+
# 5. APP SETUP
|
| 27 |
+
# Switch to the user to avoid permission errors on HF Spaces
|
| 28 |
USER user
|
| 29 |
ENV HOME=/home/user \
|
| 30 |
PATH=/home/user/.local/bin:$PATH
|
| 31 |
|
| 32 |
+
WORKDIR /home/user/app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
|
|
|
|
|
|
| 34 |
COPY --chown=user requirements.txt .
|
| 35 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 36 |
|
|
|
|
|
|
|
| 37 |
COPY --chown=user . .
|
| 38 |
|
|
|
|
| 39 |
CMD ["python", "app.py"]
|