tasmimulhuda commited on
Commit
8cca8fb
·
1 Parent(s): 4d59514
Files changed (1) hide show
  1. Dockerfile +23 -15
Dockerfile CHANGED
@@ -2,27 +2,35 @@ FROM python:3.9
2
 
3
  WORKDIR /app
4
 
 
5
  COPY ./requirements.txt requirements.txt
6
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
7
 
 
8
  COPY app/ app/
9
 
10
- RUN mkdir -p app/vector_store && chmod -R 777 app/vector_store
11
- RUN mkdir -p app/uploads && chmod -R 777 app/uploads
12
- RUN mkdir -p app/log_dir && chmod -R 777 app/log_dir
13
- RUN mkdir -p app/models && chmod -R 777 app/models
14
- RUN mkdir -p app/cache && chmod -R 777 app/cache
15
-
 
 
 
 
 
16
  ENV HF_HOME=/app/cache
17
- ENV TRANSFORMERS_CACHE=/app/cache
18
-
19
- USER appuser
20
 
21
- VOLUME ~/.cache/huggingface/hub
22
- VOLUME /app/vector_store
23
- VOLUME /app/uploads
24
- VOLUME /app/log_dir
25
- VOLUME /app/models
26
 
 
 
 
 
 
 
27
 
28
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Install required Python packages
6
  COPY ./requirements.txt requirements.txt
7
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
8
 
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
+ # Set environment variable for Hugging Face cache
23
  ENV HF_HOME=/app/cache
 
 
 
24
 
25
+ # Set to a non-root user
26
+ USER nobody
 
 
 
27
 
28
+ # Define volumes for data persistence
29
+ VOLUME /app/app/vector_store
30
+ VOLUME /app/app/uploads
31
+ VOLUME /app/app/log_dir
32
+ VOLUME /app/app/models
33
+ VOLUME /app/cache
34
 
35
+ # Command to run the application
36
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]