nilotpaldhar2004 commited on
Commit
2d93e30
·
verified ·
1 Parent(s): 15455dc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -12
Dockerfile CHANGED
@@ -1,41 +1,36 @@
 
1
  FROM python:3.11-slim
2
 
3
- # 1. Install system dependencies
4
- # We keep build-essential for any C++ extensions needed by transformers/accelerate
5
  USER root
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
- git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # 2. Setup user
12
  RUN useradd -m -u 1000 user
13
  ENV HOME=/home/user \
14
  PATH=/home/user/.local/bin:$PATH \
15
  PYTHONUNBUFFERED=1 \
16
  PYTHONDONTWRITEBYTECODE=1 \
17
- HF_HOME=/home/user/.cache/huggingface \
18
- # Ensure torch doesn't try to use too many CPU threads before the GPU kicks in
19
- OMP_NUM_THREADS=4
20
 
21
  WORKDIR $HOME/app
22
 
23
- # 3. Create cache directories
24
- # 7B models are large (~15GB), so proper cache management is vital
25
  RUN mkdir -p $HF_HOME && chown -R user:user $HOME
26
 
27
  USER user
28
 
29
  # 4. Install Python requirements
30
- # Make sure 'spaces' and 'accelerate' are in your requirements.txt
31
  COPY --chown=user requirements.txt .
32
  RUN pip install --no-cache-dir --upgrade pip && \
33
  pip install --no-cache-dir -r requirements.txt
34
 
35
- # 5. Copy application
36
  COPY --chown=user . .
37
 
38
- # Hugging Face ZeroGPU requires the app to run on port 7860
39
  EXPOSE 7860
40
 
41
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use 3.11 to maintain compatibility with Torch 2.3.0
2
  FROM python:3.11-slim
3
 
4
+ # 1. Install system dependencies for C++ builds (needed for sentencepiece)
 
5
  USER root
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ # 2. Setup non-root user for Hugging Face
11
  RUN useradd -m -u 1000 user
12
  ENV HOME=/home/user \
13
  PATH=/home/user/.local/bin:$PATH \
14
  PYTHONUNBUFFERED=1 \
15
  PYTHONDONTWRITEBYTECODE=1 \
16
+ HF_HOME=/home/user/.cache/huggingface
 
 
17
 
18
  WORKDIR $HOME/app
19
 
20
+ # 3. Initialize cache directories
 
21
  RUN mkdir -p $HF_HOME && chown -R user:user $HOME
22
 
23
  USER user
24
 
25
  # 4. Install Python requirements
 
26
  COPY --chown=user requirements.txt .
27
  RUN pip install --no-cache-dir --upgrade pip && \
28
  pip install --no-cache-dir -r requirements.txt
29
 
30
+ # 5. Copy application code
31
  COPY --chown=user . .
32
 
33
+ # 6. Expose port 7860 for Hugging Face Spaces
34
  EXPOSE 7860
35
 
36
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]