shivam98 commited on
Commit
8b031b3
·
verified ·
1 Parent(s): b4b773b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -6
Dockerfile CHANGED
@@ -3,24 +3,36 @@ FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV TZ=Etc/UTC
5
 
6
- # Use /data as HF_HOME to avoid permission issues
7
- ENV HF_HOME=/data/huggingface
8
-
9
  WORKDIR /app
10
 
 
11
  RUN apt-get update && apt-get install -y \
12
  ffmpeg \
13
  git \
14
  tzdata \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
- # Create cache directory in writable location
18
- RUN mkdir -p /data/huggingface
 
 
 
 
19
 
 
 
 
 
 
 
20
  COPY requirements.txt .
21
  RUN pip install --upgrade pip && pip install -r requirements.txt
22
 
23
- COPY main.py .
 
 
 
 
24
 
25
  EXPOSE 7860
26
 
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV TZ=Etc/UTC
5
 
 
 
 
6
  WORKDIR /app
7
 
8
+ # Install system dependencies
9
  RUN apt-get update && apt-get install -y \
10
  ffmpeg \
11
  git \
12
  tzdata \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Create a non-root user
16
+ RUN useradd -m -u 1000 user
17
+
18
+ # Create cache directory and set permissions
19
+ RUN mkdir -p /data/huggingface/hub && \
20
+ chown -R user:user /data/huggingface
21
 
22
+ # Set environment variables for HuggingFace cache
23
+ ENV HF_HOME=/data/huggingface
24
+ ENV TRANSFORMERS_CACHE=/data/huggingface/hub
25
+ ENV HF_HUB_CACHE=/data/huggingface/hub
26
+
27
+ # Copy requirements and install Python dependencies
28
  COPY requirements.txt .
29
  RUN pip install --upgrade pip && pip install -r requirements.txt
30
 
31
+ # Switch to non-root user
32
+ USER user
33
+
34
+ # Copy application code with proper ownership
35
+ COPY --chown=user:user main.py .
36
 
37
  EXPOSE 7860
38