Update Dockerfile
Browse files- Dockerfile +36 -31
Dockerfile
CHANGED
@@ -1,31 +1,36 @@
|
|
1 |
-
FROM python:3.9-slim
|
2 |
-
|
3 |
-
# Install system dependencies
|
4 |
-
RUN apt-get update && apt-get install -y \
|
5 |
-
tesseract-ocr \
|
6 |
-
tesseract-ocr-eng \
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim
|
2 |
+
|
3 |
+
# Install system dependencies
|
4 |
+
RUN apt-get update && apt-get install -y \
|
5 |
+
tesseract-ocr \
|
6 |
+
tesseract-ocr-eng \
|
7 |
+
libgl1-mesa-glx \
|
8 |
+
libglib2.0-0 \
|
9 |
+
&& rm -rf /var/lib/apt/lists/*
|
10 |
+
|
11 |
+
# Create a non-root user
|
12 |
+
RUN useradd -m -u 1000 user
|
13 |
+
USER user
|
14 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
15 |
+
|
16 |
+
# Set working directory
|
17 |
+
WORKDIR /app
|
18 |
+
|
19 |
+
# Copy requirements first to leverage Docker cache
|
20 |
+
COPY --chown=user requirements.txt .
|
21 |
+
|
22 |
+
# Install Python dependencies
|
23 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
24 |
+
pip install --no-cache-dir --user -r requirements.txt
|
25 |
+
|
26 |
+
# Download spaCy model
|
27 |
+
RUN python -m spacy download en_core_web_md
|
28 |
+
|
29 |
+
# Copy the rest of the application
|
30 |
+
COPY --chown=user . .
|
31 |
+
|
32 |
+
# Expose the port the app runs on
|
33 |
+
EXPOSE 7860
|
34 |
+
|
35 |
+
# Command to run the application
|
36 |
+
CMD ["uvicorn", "newapp:app", "--host", "0.0.0.0", "--port", "7860"]
|