Learnerbegginer commited on
Commit
499e7bd
·
verified ·
1 Parent(s): 18fada9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -7
Dockerfile CHANGED
@@ -1,22 +1,31 @@
1
  FROM python:3.9-slim
2
 
 
 
 
 
 
 
 
3
  # Set working directory
4
  WORKDIR /app
5
 
6
- # Install dependencies
7
  COPY requirements.txt .
8
  RUN pip install --no-cache-dir -r requirements.txt
9
 
10
- # Set writable cache directory
11
- ENV TRANSFORMERS_CACHE=/app/cache
12
- ENV HF_HOME=/app/cache
13
- RUN mkdir -p /app/cache
14
 
15
- # Copy all files
16
  COPY . .
 
 
 
 
17
 
18
  # Expose port for Streamlit
19
  EXPOSE 7860
20
 
21
- # Run the app
22
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
1
  FROM python:3.9-slim
2
 
3
+ # Create a non-root user
4
+ RUN useradd -m appuser
5
+
6
+ # Set environment variables for Hugging Face cache
7
+ ENV TRANSFORMERS_CACHE=/app/cache
8
+ ENV HF_HOME=/app/cache
9
+
10
  # Set working directory
11
  WORKDIR /app
12
 
13
+ # Copy requirements and install them
14
  COPY requirements.txt .
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
+ # Create cache directory and set permissions
18
+ RUN mkdir -p /app/cache && chown -R appuser /app/cache
 
 
19
 
20
+ # Copy all files and set ownership
21
  COPY . .
22
+ RUN chown -R appuser /app
23
+
24
+ # Switch to non-root user
25
+ USER appuser
26
 
27
  # Expose port for Streamlit
28
  EXPOSE 7860
29
 
30
+ # Run the Streamlit app
31
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]