-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.build
More file actions
56 lines (39 loc) · 1.6 KB
/
Dockerfile.build
File metadata and controls
56 lines (39 loc) · 1.6 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
ARG PYTHON_VERSION_TAG=3.14
FROM python:$PYTHON_VERSION_TAG AS python-builder
WORKDIR /home/nonroot
ENV UV_LINK_MODE=copy
ENV UV_LOCKED=1
ENV UV_NO_DEV=1
ENV UV_NO_CACHE=1
ENV UV_NO_EDITABLE=1
ENV PYTHONOPTIMIZE=2
ENV RUSTFLAGS="-C target-cpu=native"
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/
COPY . .
RUN uv sync --package server
RUN find .venv /usr/local/lib -name '*.so*' -type f -exec strip --strip-unneeded {} + 2>/dev/null
FROM python:slim AS model-builder
RUN pip install huggingface_hub
RUN python -c \
"from huggingface_hub import snapshot_download; snapshot_download('distil-whisper/distil-large-v3.5-ct2')"
FROM gcr.io/distroless/python3-debian13:nonroot AS distroless
FROM busybox AS distroless-trimmed
COPY --from=distroless / /distroless/
RUN rm -rf /distroless/usr/bin/python3* /distroless/usr/lib/python3*
FROM scratch
ARG PYTHON_VERSION_TAG
ENV HOME=/home/nonroot
ENV PATH=$HOME/.venv/bin:/usr/local/bin:$PATH
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV HF_HUB_OFFLINE=1
COPY --from=distroless-trimmed /distroless/ /
COPY --from=model-builder /root/.cache/huggingface $HOME/.cache/huggingface
COPY --from=model-builder /usr/local/lib/libpython* /usr/local/lib/
COPY --from=python-builder /usr/local/lib/python$PYTHON_VERSION_TAG /usr/local/lib/python$PYTHON_VERSION_TAG
COPY --from=python-builder /usr/local/bin/python$PYTHON_VERSION_TAG /usr/local/bin/
COPY --from=python-builder /usr/local/bin/python3 /usr/local/bin/
COPY --from=python-builder /usr/lib/ssl /usr/lib/ssl
COPY --from=python-builder $HOME/.venv $HOME/.venv
USER nonroot
CMD ["capgen"]