RajanMalaviya commited on
Commit
f58bd0b
·
verified ·
1 Parent(s): bc73dcf

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -29
Dockerfile CHANGED
@@ -1,30 +1,41 @@
1
- FROM python:3.10-slim
2
-
3
- # Install system dependencies
4
- RUN apt-get update && apt-get install -y \
5
- tesseract-ocr \
6
- tesseract-ocr-eng \
7
- tesseract-ocr-ara \
8
- poppler-utils \
9
- libopencv-dev \
10
- && apt-get clean \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # Set Tesseract path
14
- ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata/
15
-
16
- # Set working directory
17
- WORKDIR /app
18
-
19
- # Copy requirements and install
20
- COPY requirements.txt .
21
- RUN pip install --no-cache-dir -r requirements.txt
22
-
23
- # Copy application code
24
- COPY app.py .
25
-
26
- # Expose port for FastAPI
27
- EXPOSE 7860
28
-
29
- # Command to run the app
 
 
 
 
 
 
 
 
 
 
 
30
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.10-slim
2
+
3
+ # Install system dependencies
4
+ RUN apt-get update && apt-get install -y \
5
+ tesseract-ocr \
6
+ tesseract-ocr-eng \
7
+ tesseract-ocr-ara \
8
+ poppler-utils \
9
+ libopencv-dev \
10
+ && apt-get clean \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Set Tesseract path
14
+ ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata/
15
+
16
+ # Create a non-root user and set up cache directory
17
+ RUN useradd -m appuser && \
18
+ mkdir -p /app/cache && \
19
+ chown -R appuser:appuser /app
20
+
21
+ # Set working directory
22
+ WORKDIR /app
23
+
24
+ # Copy requirements and install
25
+ COPY requirements.txt .
26
+ RUN pip install --no-cache-dir -r requirements.txt
27
+
28
+ # Copy application code
29
+ COPY app.py .
30
+
31
+ # Switch to non-root user
32
+ USER appuser
33
+
34
+ # Set Hugging Face cache directory
35
+ ENV HF_HOME=/app/cache
36
+
37
+ # Expose port for FastAPI
38
+ EXPOSE 7860
39
+
40
+ # Command to run the app
41
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]