chitkenkhoi commited on
Commit
1c9f5b4
·
1 Parent(s): 7936e19
Files changed (1) hide show
  1. Dockerfile +22 -0
Dockerfile CHANGED
@@ -1,10 +1,32 @@
1
  FROM python:3.9
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  WORKDIR /code
4
 
 
5
  COPY ./requirements.txt /code/requirements.txt
6
  RUN pip install --no-cache-dir -r requirements.txt
7
 
 
8
  COPY ./app.py /code/app.py
9
 
 
 
 
 
 
 
 
10
  CMD ["python", "app.py"]
 
1
  FROM python:3.9
2
 
3
+ # Create a non-root user
4
+ RUN useradd -m -u 1000 user
5
+
6
+ # Create cache directory and set permissions
7
+ RUN mkdir -p /home/user/.cache/huggingface && \
8
+ mkdir -p /home/user/.cache/torch && \
9
+ chown -R user:user /home/user/.cache
10
+
11
+ # Set environment variables
12
+ ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface
13
+ ENV TORCH_HOME=/home/user/.cache/torch
14
+ ENV HF_HOME=/home/user/.cache/huggingface
15
+
16
  WORKDIR /code
17
 
18
+ # Copy and install requirements
19
  COPY ./requirements.txt /code/requirements.txt
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
+ # Copy application code
23
  COPY ./app.py /code/app.py
24
 
25
+ # Change ownership of the application directory
26
+ RUN chown -R user:user /code
27
+
28
+ # Switch to non-root user
29
+ USER user
30
+
31
+ # Run the application
32
  CMD ["python", "app.py"]