Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +23 -16
Dockerfile
CHANGED
|
@@ -1,38 +1,45 @@
|
|
| 1 |
FROM mambaorg/micromamba:1.5.3
|
| 2 |
|
| 3 |
-
# Switch to root
|
| 4 |
USER root
|
| 5 |
-
|
| 6 |
-
# Create the working directory and ensure the user owns it
|
| 7 |
WORKDIR /app
|
| 8 |
RUN chown -R mambauser:mambauser /app
|
| 9 |
|
| 10 |
-
# Switch back to the non-root user
|
| 11 |
USER mambauser
|
| 12 |
|
| 13 |
-
# Initialize
|
| 14 |
RUN micromamba shell init --shell=bash --root-prefix=~/micromamba
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
micromamba clean --all --yes
|
| 22 |
|
| 23 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
ARG MAMBA_DOCKERFILE_ACTIVATE=1
|
|
|
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
-
# Download
|
| 28 |
-
# We download it now so the space starts fast
|
| 29 |
RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='Qwen/Qwen2.5-1.5B-Instruct-GGUF', filename='qwen2.5-1.5b-instruct-q4_k_m.gguf', local_dir='./models')"
|
| 30 |
|
| 31 |
-
# Copy the
|
| 32 |
COPY --chown=mambauser:mambauser . /app
|
| 33 |
|
| 34 |
-
# Expose the single allowed port
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
-
# Start the
|
| 38 |
CMD ["python", "main.py"]
|
|
|
|
| 1 |
FROM mambaorg/micromamba:1.5.3
|
| 2 |
|
| 3 |
+
# 1. Switch to root to set permissions (Standard HF Space requirement)
|
| 4 |
USER root
|
|
|
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
RUN chown -R mambauser:mambauser /app
|
| 7 |
|
| 8 |
+
# 2. Switch back to the non-root user
|
| 9 |
USER mambauser
|
| 10 |
|
| 11 |
+
# 3. Initialize the shell
|
| 12 |
RUN micromamba shell init --shell=bash --root-prefix=~/micromamba
|
| 13 |
|
| 14 |
+
# 4. Install Python AND Compilers (gcc, g++, cmake)
|
| 15 |
+
# We need these to build llama-cpp-python and for the AI to compile tools later
|
| 16 |
+
RUN micromamba install -y -n base \
|
| 17 |
+
python=3.10 \
|
| 18 |
+
pip \
|
| 19 |
+
cmake \
|
| 20 |
+
make \
|
| 21 |
+
gcc_linux-64 \
|
| 22 |
+
gxx_linux-64 \
|
| 23 |
+
-c conda-forge && \
|
| 24 |
micromamba clean --all --yes
|
| 25 |
|
| 26 |
+
# 5. Copy requirements
|
| 27 |
+
COPY --chown=mambauser:mambauser requirements.txt /app/requirements.txt
|
| 28 |
+
|
| 29 |
+
# 6. Install Python packages
|
| 30 |
+
# We set CMAKE_ARGS to ensure it builds for CPU specifically
|
| 31 |
ARG MAMBA_DOCKERFILE_ACTIVATE=1
|
| 32 |
+
ENV CMAKE_ARGS="-DLLAMA_BLAS=OFF"
|
| 33 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 34 |
|
| 35 |
+
# 7. Download the Model (Qwen 2.5 1.5B - Fast CPU)
|
|
|
|
| 36 |
RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='Qwen/Qwen2.5-1.5B-Instruct-GGUF', filename='qwen2.5-1.5b-instruct-q4_k_m.gguf', local_dir='./models')"
|
| 37 |
|
| 38 |
+
# 8. Copy the application code
|
| 39 |
COPY --chown=mambauser:mambauser . /app
|
| 40 |
|
| 41 |
+
# 9. Expose the single allowed port
|
| 42 |
EXPOSE 7860
|
| 43 |
|
| 44 |
+
# 10. Start the app
|
| 45 |
CMD ["python", "main.py"]
|