abdullahalioo commited on
Commit
9865905
·
verified ·
1 Parent(s): 2ba12d8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -14
Dockerfile CHANGED
@@ -5,19 +5,21 @@ WORKDIR /app
5
 
6
  # Install system dependencies
7
  RUN apt-get update && \
8
- apt-get install -y --no-install-recommends build-essential && \
9
- rm -rf /var/lib/apt/lists/*
 
 
10
 
11
- # Create and set writable cache directories with proper permissions
12
- RUN mkdir -p /tmp/hf_cache && \
13
- chmod -R 777 /tmp/hf_cache
14
 
15
- # Set environment variables for Hugging Face cache
16
- ENV HF_HOME=/tmp/hf_cache
17
- ENV TRANSFORMERS_CACHE=/tmp/hf_cache
18
- ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_cache
19
 
20
- # Copy requirements first to leverage Docker cache
21
  COPY requirements.txt .
22
 
23
  # Install Python dependencies
@@ -27,12 +29,15 @@ RUN pip install --upgrade pip && \
27
  # Copy application code
28
  COPY . .
29
 
30
- # Expose port
31
- EXPOSE 7860
 
 
32
 
33
- # Run as non-root user for better security
34
- RUN useradd -m myuser && chown -R myuser /app
35
  USER myuser
36
 
 
 
 
37
  # Run the app
38
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
5
 
6
  # Install system dependencies
7
  RUN apt-get update && \
8
+ apt-get install -y --no-install-recommends \
9
+ build-essential \
10
+ git \
11
+ && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Create and set cache directory
14
+ RUN mkdir -p /tmp/hf_home && \
15
+ chmod -R 777 /tmp/hf_home
16
 
17
+ # Set environment variables
18
+ ENV HF_HOME=/tmp/hf_home
19
+ ENV TRANSFORMERS_CACHE=/tmp/hf_home
20
+ ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_home
21
 
22
+ # Copy requirements first
23
  COPY requirements.txt .
24
 
25
  # Install Python dependencies
 
29
  # Copy application code
30
  COPY . .
31
 
32
+ # Create non-root user
33
+ RUN useradd -m myuser && \
34
+ chown -R myuser /app && \
35
+ chown -R myuser /tmp/hf_home
36
 
 
 
37
  USER myuser
38
 
39
+ # Expose port
40
+ EXPOSE 7860
41
+
42
  # Run the app
43
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]