Noha90 commited on
Commit
ae52f76
·
1 Parent(s): d22fb9d

Fix permissions and dependencies

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -13
  2. requirements.txt +2 -0
Dockerfile CHANGED
@@ -2,30 +2,28 @@ FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
5
- # Install system dependencies
6
  RUN apt-get update && \
7
  apt-get install -y --no-install-recommends \
8
  build-essential \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Set environment variables
12
- ENV TRANSFORMERS_CACHE=/tmp/huggingface
 
 
 
13
  ENV PORT=7860
14
 
15
- # Create cache directory with proper permissions
16
- RUN mkdir -p /tmp/huggingface && chmod 777 /tmp/huggingface
17
 
18
- # Copy requirements first to leverage Docker cache
19
- COPY requirements.txt .
20
 
21
- # Install specific numpy version first
22
- RUN pip install --no-cache-dir numpy==1.24.3
23
 
24
- # Then install other requirements
25
- RUN pip install --no-cache-dir -r requirements.txt
26
 
27
- # Copy the rest of the application
28
- COPY . .
29
 
30
  EXPOSE 7860
31
 
 
2
 
3
  WORKDIR /app
4
 
 
5
  RUN apt-get update && \
6
  apt-get install -y --no-install-recommends \
7
  build-essential \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ RUN useradd -m -u 1000 user && \
11
+ chown -R user:user /app
12
+
13
+ ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
14
+ ENV HF_HOME=/app/.cache/huggingface
15
  ENV PORT=7860
16
 
17
+ RUN mkdir -p /app/.cache/huggingface && \
18
+ chown -R user:user /app/.cache
19
 
20
+ USER user
 
21
 
22
+ COPY --chown=user:user requirements.txt .
 
23
 
24
+ RUN pip install --no-cache-dir --user -r requirements.txt
 
25
 
26
+ COPY --chown=user:user . .
 
27
 
28
  EXPOSE 7860
29
 
requirements.txt CHANGED
@@ -1,6 +1,8 @@
 
1
  flask==2.0.1
2
  transformers==4.30.2
3
  torch==2.0.1
 
4
  safetensors==0.3.1
5
  werkzeug==2.0.3
6
  gunicorn==20.1.0
 
1
+ numpy==1.24.3
2
  flask==2.0.1
3
  transformers==4.30.2
4
  torch==2.0.1
5
+ tokenizers==0.13.3
6
  safetensors==0.3.1
7
  werkzeug==2.0.3
8
  gunicorn==20.1.0