Update Dockerfile
Browse files- 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 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"]
|