-
Notifications
You must be signed in to change notification settings - Fork 693
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (48 loc) · 2.2 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (48 loc) · 2.2 KB
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
FROM python:3.10-slim
ARG MIRROR
ARG APT_MIRROR
LABEL authors="nexent"
# Set correct permissions as root
USER root
# Configure apt sources based on build argument
RUN if [ "$APT_MIRROR" = "tsinghua" ]; then \
rm -f /etc/apt/sources.list.d/* && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list; \
fi && \
apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
apt-get install -y --no-install-recommends --fix-missing \
curl \
libmagic1 \
libmagic-dev \
libreoffice \
libgl1 \
coreutils \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN pip install --no-cache-dir uv $(test -n "$MIRROR" && echo "-i $MIRROR")
# Layer 0: copy model assets
COPY model-assets/clip-vit-base-patch32 /opt/models/clip-vit-base-patch32
COPY model-assets/nltk_data /opt/models/nltk_data
WORKDIR /opt/backend
# Layer 1: install base dependencies
COPY backend/pyproject.toml /opt/backend/pyproject.toml
RUN uv sync --no-cache-dir --extra data-process $(test -n "$MIRROR" && echo "-i $MIRROR") && \
uv cache clean
# Layer 2: install sdk in link mode
COPY sdk /opt/sdk
RUN uv pip install --no-cache-dir /opt/sdk $(test -n "$MIRROR" && echo "-i $MIRROR") && \
uv cache clean
# Pre-download tiktoken cl100k_base model to avoid network issues during runtime
RUN uv run python -c "import tiktoken; enc = tiktoken.get_encoding('cl100k_base')"
# Layer 3: copy backend code
COPY backend /opt/backend
ENV VIRTUAL_ENV=/opt/backend/.venv
ENV PATH="$VIRTUAL_ENV/bin:/usr/bin:/bin:/usr/local/bin:$PATH"
WORKDIR /opt
# Expose the service port
EXPOSE 5012