forked from sambanova/ai-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
81 lines (64 loc) · 1.88 KB
/
Dockerfile
1
2
3
4
5
6
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Use an official Python runtime as a parent image
FROM python:3.11.5-bookworm as builder
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
poppler-utils \
tesseract-ocr \
qpdf \
make \
ffmpeg \
libsm6 \
libxext6 \
&& rm -rf /var/lib/apt/lists/*
# Set working directory in the container
WORKDIR /app
# Copy only the requirements files first
COPY base-requirements.txt tests/requirements.txt ./
# Upgrade pip and install project dependencies
RUN pip install --upgrade pip
# Use BuildKit's cache mount to speed up pip installs
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r base-requirements.txt
# Final stage
FROM python:3.11.5-slim-bookworm
# Copy installed packages from builder stage
COPY --from=builder /usr/local /usr/local
# Install runtime system dependencies and build tools
RUN apt-get update && apt-get install -y \
build-essential \
python3-dev \
poppler-utils \
tesseract-ocr \
qpdf \
make \
ffmpeg \
libsm6 \
libxext6 \
&& rm -rf /var/lib/apt/lists/*
# Set working directory in the container
WORKDIR /app
# Copy the application code (excluding .env file)
COPY . .
RUN rm -f .env
# Add build argument for parsing service setup
ARG SETUP_PARSING_SERVICE=no
# Set up parsing service conditionally
RUN if [ "$SETUP_PARSING_SERVICE" = "yes" ]; then \
cd utils/parsing/unstructured-api && \
make install; \
fi
# Copy the startup script and make it executable
COPY docker-startup.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-startup.sh
# Expose the ports for the parsing service and Streamlit
EXPOSE 8005 8501
# Set the startup script as the entrypoint
ENTRYPOINT ["/usr/local/bin/docker-startup.sh"]
# Default command
CMD ["make", "run"]