1
+ FROM lukemathwalker/cargo-chef:latest-rust-1.85-bookworm AS chef
2
+ WORKDIR /usr/src
3
+
4
+ ENV SCCACHE=0.10.0
5
+ ENV RUSTC_WRAPPER=/usr/local/bin/sccache
6
+
7
+ # Download, configure sccache
8
+ RUN curl -fsSL https://github.com/mozilla/sccache/releases/download/v$SCCACHE/sccache-v$SCCACHE-x86_64-unknown-linux-musl.tar.gz | tar -xzv --strip-components=1 -C /usr/local/bin sccache-v$SCCACHE-x86_64-unknown-linux-musl/sccache && \
9
+ chmod +x /usr/local/bin/sccache
10
+
11
+ FROM chef AS planner
12
+
13
+ COPY backends backends
14
+ COPY core core
15
+ COPY router router
16
+ COPY Cargo.toml ./
17
+ COPY Cargo.lock ./
18
+
19
+ RUN cargo chef prepare --recipe-path recipe.json
20
+
21
+ FROM chef AS builder
22
+
23
+ ARG GIT_SHA
24
+ ARG DOCKER_LABEL
25
+
26
+ # sccache specific variables
27
+ ARG SCCACHE_GHA_ENABLED
28
+
29
+ # Install build dependencies without Intel MKL for AMD compatibility
30
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
31
+ build-essential \
32
+ libomp-dev \
33
+ && rm -rf /var/lib/apt/lists/*
34
+
35
+ COPY --from=planner /usr/src/recipe.json recipe.json
36
+
37
+ # Build without Intel MKL feature for AMD CPU compatibility
38
+ RUN --mount=type=secret,id=actions_results_url,env=ACTIONS_RESULTS_URL \
39
+ --mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
40
+ cargo chef cook --release --features ort,candle --no-default-features --recipe-path recipe.json && sccache -s
41
+
42
+ COPY backends backends
43
+ COPY core core
44
+ COPY router router
45
+ COPY Cargo.toml ./
46
+ COPY Cargo.lock ./
47
+
48
+ FROM builder AS http-builder
49
+
50
+ RUN --mount=type=secret,id=actions_results_url,env=ACTIONS_RESULTS_URL \
51
+ --mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
52
+ cargo build --release --bin text-embeddings-router --features ort,candle,http --no-default-features && sccache -s
53
+
54
+ FROM builder AS grpc-builder
55
+
56
+ RUN PROTOC_ZIP=protoc-21.12-linux-x86_64.zip && \
57
+ curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/$PROTOC_ZIP && \
58
+ unzip -o $PROTOC_ZIP -d /usr/local bin/protoc && \
59
+ unzip -o $PROTOC_ZIP -d /usr/local 'include/*' && \
60
+ rm -f $PROTOC_ZIP
61
+
62
+ COPY proto proto
63
+
64
+ RUN --mount=type=secret,id=actions_results_url,env=ACTIONS_RESULTS_URL \
65
+ --mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
66
+ cargo build --release --bin text-embeddings-router --features ort,candle,grpc --no-default-features && sccache -s
67
+
68
+ FROM debian:bookworm-slim AS base
69
+
70
+ # Environment variables without Intel MKL specific settings
71
+ ENV HUGGINGFACE_HUB_CACHE=/data \
72
+ PORT=80 \
73
+ RAYON_NUM_THREADS=8
74
+
75
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
76
+ libomp-dev \
77
+ ca-certificates \
78
+ libssl-dev \
79
+ curl \
80
+ && rm -rf /var/lib/apt/lists/*
81
+
82
+ FROM base AS grpc
83
+
84
+ COPY --from=grpc-builder /usr/src/target/release/text-embeddings-router /usr/local/bin/text-embeddings-router
85
+
86
+ ENTRYPOINT ["text-embeddings-router"]
87
+ CMD ["--json-output"]
88
+
89
+ FROM base AS http
90
+
91
+ COPY --from=http-builder /usr/src/target/release/text-embeddings-router /usr/local/bin/text-embeddings-router
92
+
93
+ # Amazon SageMaker compatible image
94
+ FROM http AS sagemaker
95
+ COPY --chmod=775 sagemaker-entrypoint.sh entrypoint.sh
96
+
97
+ ENTRYPOINT ["./entrypoint.sh"]
98
+
99
+ # Default image
100
+ FROM http
101
+
102
+ ENTRYPOINT ["text-embeddings-router"]
103
+ CMD ["--json-output"]
0 commit comments