rodrigomasini's picture
Update Dockerfile
f6a3cf4 verified
raw
history blame
1.21 kB
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
MDR_MODEL_DIR=/models \
MDR_DEVICE=cpu \
MDR_TABLE_FORMAT=MARKDOWN \
LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# Set the working directory in the container
WORKDIR /app
# Install system dependencies required by OpenCV and potentially others
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libfreetype6-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the container
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the application code into the container
COPY mdr_pdf_parser.py .
COPY main.py .
# Create the default model directory and a temp directory
RUN mkdir -p ${MDR_MODEL_DIR} /app/temp_uploads && \
chmod -R 777 ${MDR_MODEL_DIR} /app/temp_uploads
# Expose the port the app runs on
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
# This allows mounting a host directory for persistent models
VOLUME ${MDR_MODEL_DIR}