diamond-in commited on
Commit
e01c60f
·
verified ·
1 Parent(s): c0e62cf

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -16
Dockerfile CHANGED
@@ -1,38 +1,45 @@
1
  FROM mambaorg/micromamba:1.5.3
2
 
3
- # Switch to root briefly to setup permissions (standard HF requirement)
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 provided by the image
11
  USER mambauser
12
 
13
- # Initialize shell for the user
14
  RUN micromamba shell init --shell=bash --root-prefix=~/micromamba
15
 
16
- # Copy requirements first to leverage caching
17
- COPY --chown=mambauser:mambauser requirements.txt /app/requirements.txt
18
-
19
- # Install Python and Pip dependencies via Micromamba to avoid system conflicts
20
- RUN micromamba install -y -n base python=3.10 pip -c conda-forge && \
 
 
 
 
 
21
  micromamba clean --all --yes
22
 
23
- # Activate the environment and install pip packages
 
 
 
 
24
  ARG MAMBA_DOCKERFILE_ACTIVATE=1
 
25
  RUN pip install --no-cache-dir -r requirements.txt
26
 
27
- # Download a fast, small CPU model (Qwen 2.5 1.5B Instruct)
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 rest of the application
32
  COPY --chown=mambauser:mambauser . /app
33
 
34
- # Expose the single allowed port
35
  EXPOSE 7860
36
 
37
- # Start the application
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"]