Create Dockerfile
Browse files- Dockerfile +44 -0
Dockerfile
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11-slim
|
2 |
+
|
3 |
+
# Set environment variables
|
4 |
+
ENV PYTHONUNBUFFERED=1 \
|
5 |
+
MDR_MODEL_DIR=/models \
|
6 |
+
MDR_DEVICE=cpu \
|
7 |
+
MDR_TABLE_FORMAT=MARKDOWN \
|
8 |
+
LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
|
9 |
+
|
10 |
+
# Set the working directory in the container
|
11 |
+
WORKDIR /app
|
12 |
+
|
13 |
+
# Install system dependencies required by OpenCV and potentially others
|
14 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
15 |
+
libgl1-mesa-glx \
|
16 |
+
libglib2.0-0 \
|
17 |
+
libsm6 \
|
18 |
+
libxext6 \
|
19 |
+
libxrender-dev \
|
20 |
+
libfreetype6-dev \
|
21 |
+
&& rm -rf /var/lib/apt/lists/*
|
22 |
+
|
23 |
+
# Copy the requirements file into the container
|
24 |
+
COPY requirements.txt .
|
25 |
+
|
26 |
+
# Install Python dependencies
|
27 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
28 |
+
pip install --no-cache-dir -r requirements.txt
|
29 |
+
|
30 |
+
# Copy the application code into the container
|
31 |
+
COPY magic_pdf_processor.py .
|
32 |
+
COPY main.py .
|
33 |
+
|
34 |
+
# Create the default model directory and a temp directory
|
35 |
+
RUN mkdir -p ${MDR_MODEL_DIR} /app/temp_uploads && \
|
36 |
+
chmod -R 777 ${MDR_MODEL_DIR} /app/temp_uploads
|
37 |
+
|
38 |
+
# Expose the port the app runs on
|
39 |
+
EXPOSE 8000
|
40 |
+
|
41 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
42 |
+
|
43 |
+
# This allows mounting a host directory for persistent models
|
44 |
+
VOLUME ${MDR_MODEL_DIR}
|