tasmimulhuda commited on
Commit
ba44bc5
·
1 Parent(s): 2190537

docker issue permission

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -12
Dockerfile CHANGED
@@ -1,5 +1,9 @@
1
  FROM python:3.9
2
 
 
 
 
 
3
  WORKDIR /app
4
 
5
  # Install required Python packages
@@ -9,26 +13,22 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
9
  # Copy application code
10
  COPY app/ app/
11
 
12
- # Create directories for the Hugging Face cache and application data
13
  RUN mkdir -p /app/cache && \
14
  mkdir -p /app/app/vector_store && \
15
  mkdir -p /app/app/uploads && \
16
  mkdir -p /app/app/log_dir && \
17
- mkdir -p /app/app/models && \
18
  # Adjust ownership to allow writing
19
- chown -R nobody:nogroup /app/cache && \
20
- chown -R nobody:nogroup /app/app
21
-
22
- WORKDIR /app
23
-
24
- RUN mkdir -p app/app/models/models--sentence-transformers--all-MiniLM-L6-v2 && \
25
- chmod -R 777 app/app/models/models--sentence-transformers--all-MiniLM-L6-v2
26
 
27
  # Set environment variable for Hugging Face cache
28
  ENV HF_HOME=/app/cache
29
 
30
- # Set to a non-root user
31
- USER nobody
32
 
33
  # Define volumes for data persistence
34
  VOLUME /app/app/vector_store
@@ -36,7 +36,6 @@ VOLUME /app/app/uploads
36
  VOLUME /app/app/log_dir
37
  VOLUME /app/app/models
38
  VOLUME /app/cache
39
- VOLUME /app/app/models/models--sentence-transformers--all-MiniLM-L6-v2
40
 
41
  # Command to run the application
42
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.9
2
 
3
+ # Create a user and switch to it
4
+ RUN useradd -ms /bin/bash appuser
5
+
6
+ # Set working directory
7
  WORKDIR /app
8
 
9
  # Install required Python packages
 
13
  # Copy application code
14
  COPY app/ app/
15
 
16
+ # Create necessary directories and adjust ownership
17
  RUN mkdir -p /app/cache && \
18
  mkdir -p /app/app/vector_store && \
19
  mkdir -p /app/app/uploads && \
20
  mkdir -p /app/app/log_dir && \
21
+ mkdir -p /app/app/models/models--sentence-transformers--all-MiniLM-L6-v2 && \
22
  # Adjust ownership to allow writing
23
+ chown -R appuser:appuser /app/cache && \
24
+ chown -R appuser:appuser /app/app && \
25
+ chmod -R 777 /app/app/models/models--sentence-transformers--all-MiniLM-L6-v2
 
 
 
 
26
 
27
  # Set environment variable for Hugging Face cache
28
  ENV HF_HOME=/app/cache
29
 
30
+ # Switch to non-root user
31
+ # USER appuser
32
 
33
  # Define volumes for data persistence
34
  VOLUME /app/app/vector_store
 
36
  VOLUME /app/app/log_dir
37
  VOLUME /app/app/models
38
  VOLUME /app/cache
 
39
 
40
  # Command to run the application
41
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]