agentsay commited on
Commit
72800b1
·
verified ·
1 Parent(s): ed5253d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -15
Dockerfile CHANGED
@@ -1,5 +1,6 @@
1
  FROM python:3.11-slim
2
 
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
@@ -8,27 +9,29 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
8
  libglib2.0-0 \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Create directories with proper permissions and ownership
12
- RUN mkdir -p /app/data/chroma_crop_rag /app/cache && \
13
- chmod -R 777 /app/data /app/cache && \
14
- chown -R root:root /app/data /app/cache && \
15
- rm -rf /app/data/chroma_crop_rag/* /app/cache/*.lock
16
 
17
- # Set HF_HOME for HuggingFace models
18
- ENV HF_HOME=/app/cache
 
 
 
19
 
20
- # Debug: List build context contents
21
- RUN ls -la .
22
 
23
- # Copy files (skip chroma_crop_rag to avoid build error)
24
- # COPY chroma_crop_rag /app/data/chroma_crop_rag
25
  COPY requirements.txt api.py config.py crop_disease_qa.json /app/
26
 
27
- # Install dependencies
28
  RUN pip install --no-cache-dir python-multipart -r requirements.txt
29
 
30
- # Debug: List files and permissions to verify
31
- RUN ls -la /app/data /app/cache
32
 
 
33
  EXPOSE 7860
34
- CMD ["python", "api.py"]
 
 
 
1
  FROM python:3.11-slim
2
 
3
+ # Set working directory
4
  WORKDIR /app
5
 
6
  # Install system dependencies
 
9
  libglib2.0-0 \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create required directories with wide access
13
+ RUN mkdir -p /app/data/chroma_crop_rag /app/cache
 
 
 
14
 
15
+ # Add a non-root user
16
+ RUN useradd -m appuser
17
+
18
+ # Set ownership of relevant directories to non-root user
19
+ RUN chown -R appuser:appuser /app/data /app/cache
20
 
21
+ # Set environment variable for HuggingFace cache
22
+ ENV HF_HOME=/app/cache
23
 
24
+ # Copy application files
 
25
  COPY requirements.txt api.py config.py crop_disease_qa.json /app/
26
 
27
+ # Install Python dependencies
28
  RUN pip install --no-cache-dir python-multipart -r requirements.txt
29
 
30
+ # Change to non-root user
31
+ USER appuser
32
 
33
+ # Expose the application port
34
  EXPOSE 7860
35
+
36
+ # Run the app
37
+ CMD ["python", "api.py"]