ateetvatan commited on
Commit
061676c
ยท
1 Parent(s): 6b456ee

changes for 8 cpu

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -16
Dockerfile CHANGED
@@ -1,40 +1,39 @@
1
- # Base image
2
  FROM python:3.10-slim
3
 
4
- # Create non-root user (required for Hugging Face Spaces)
5
  RUN useradd -m -u 1000 user
6
 
7
- # Set paths
8
- ENV HOME=/home/user
9
- ENV APP_HOME=$HOME/app
10
- ENV HF_HOME=$HOME/.hf_home
 
11
 
12
- # Use app directory
13
  WORKDIR $APP_HOME
14
 
15
- # Switch to root for system setup
16
  USER root
17
-
18
- # Install system dependencies
19
  RUN apt-get update && apt-get install -y \
20
  git curl \
21
  && rm -rf /var/lib/apt/lists/*
22
 
23
- # Copy requirements.txt and install Python dependencies
24
  COPY --chown=user:user requirements.txt .
25
  RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
26
 
27
- # Copy app code
28
  COPY --chown=user:user . .
29
 
30
- # Ensure cache directories exist and are user-writable
31
  RUN mkdir -p $HF_HOME && chown -R user:user $HF_HOME
32
 
33
- # Set to non-root user (required for HF Spaces)
34
  USER user
35
 
36
- # Expose default port
37
  EXPOSE 7860
38
 
39
- # Entrypoint
40
  CMD ["python", "app.py"]
 
1
+ # ๐Ÿ”น Base image
2
  FROM python:3.10-slim
3
 
4
+ # ๐Ÿ”น Create Hugging Face-compliant non-root user
5
  RUN useradd -m -u 1000 user
6
 
7
+ # ๐Ÿ”น Set environment variables
8
+ ENV HOME=/home/user \
9
+ APP_HOME=/home/user/app \
10
+ HF_HOME=/home/user/.hf_home \
11
+ OMP_NUM_THREADS=8 # โœ… Use all 8 vCPUs
12
 
13
+ # ๐Ÿ”น Set working directory
14
  WORKDIR $APP_HOME
15
 
16
+ # ๐Ÿ”น Install system dependencies (root)
17
  USER root
 
 
18
  RUN apt-get update && apt-get install -y \
19
  git curl \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
+ # ๐Ÿ”น Install Python dependencies
23
  COPY --chown=user:user requirements.txt .
24
  RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
25
 
26
+ # ๐Ÿ”น Copy app code and give ownership to non-root user
27
  COPY --chown=user:user . .
28
 
29
+ # ๐Ÿ”น Ensure HF model cache dir is writable
30
  RUN mkdir -p $HF_HOME && chown -R user:user $HF_HOME
31
 
32
+ # ๐Ÿ”น Switch to non-root user (required by HF Spaces)
33
  USER user
34
 
35
+ # ๐Ÿ”น Expose the FastAPI port
36
  EXPOSE 7860
37
 
38
+ # ๐Ÿ”น Start your app
39
  CMD ["python", "app.py"]