|
| 1 | +FROM lukemathwalker/cargo-chef:latest-rust-1.92-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 and configure ARM64-compatible sccache |
| 8 | +RUN curl -fsSL https://github.com/mozilla/sccache/releases/download/v$SCCACHE/sccache-v$SCCACHE-aarch64-unknown-linux-musl.tar.gz | tar -xzv --strip-components=1 -C /usr/local/bin sccache-v$SCCACHE-aarch64-unknown-linux-musl/sccache && \ |
| 9 | + chmod +x /usr/local/bin/sccacheExpand commentComment on line R9Resolved |
| 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 | +COPY --from=planner /usr/src/recipe.json recipe.json |
| 30 | + |
| 31 | +RUN --mount=type=secret,id=actions_results_url,env=ACTIONS_RESULTS_URL \ |
| 32 | + --mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \ |
| 33 | + cargo chef cook --release --features ort,candle,static-linking --no-default-features --recipe-path recipe.json && sccache -s |
| 34 | + |
| 35 | +COPY backends backends |
| 36 | +COPY core core |
| 37 | +COPY router router |
| 38 | +COPY Cargo.toml ./ |
| 39 | +COPY Cargo.lock ./ |
| 40 | + |
| 41 | +FROM builder AS http-builder |
| 42 | + |
| 43 | +RUN --mount=type=secret,id=actions_results_url,env=ACTIONS_RESULTS_URL \ |
| 44 | + --mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \ |
| 45 | + cargo build --release --bin text-embeddings-router --features ort,candle,static-linking,http --no-default-features && sccache -s |
| 46 | + |
| 47 | +FROM builder AS grpc-builder |
| 48 | + |
| 49 | +RUN PROTOC_ZIP=protoc-21.12-linux-aarch_64.zip && \ |
| 50 | + curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/$PROTOC_ZIP && \ |
| 51 | + unzip -o $PROTOC_ZIP -d /usr/local bin/protoc && \ |
| 52 | + unzip -o $PROTOC_ZIP -d /usr/local 'include/*' && \ |
| 53 | + rm -f $PROTOC_ZIPExpand commentComment on line R53Resolved |
| 54 | + |
| 55 | +COPY proto proto |
| 56 | + |
| 57 | +RUN --mount=type=secret,id=actions_results_url,env=ACTIONS_RESULTS_URL \ |
| 58 | + --mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \ |
| 59 | + cargo build --release --bin text-embeddings-router --features ort,candle,static-linking,grpc --no-default-features && sccache -s |
| 60 | + |
| 61 | +FROM debian:bookworm-slim AS base |
| 62 | + |
| 63 | +ENV HUGGINGFACE_HUB_CACHE=/data \ |
| 64 | + PORT=80 \ |
| 65 | + RAYON_NUM_THREADS=8 \ |
| 66 | + LD_LIBRARY_PATH=/usr/local/lib |
| 67 | + |
| 68 | +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| 69 | + libomp-dev \ |
| 70 | + ca-certificates \ |
| 71 | + libssl-dev \ |
| 72 | + curl \ |
| 73 | + && rm -rf /var/lib/apt/lists/* |
| 74 | + |
| 75 | +FROM base AS grpc |
| 76 | + |
| 77 | +COPY --from=grpc-builder /usr/src/target/release/text-embeddings-router /usr/local/bin/text-embeddings-router |
| 78 | + |
| 79 | +ENTRYPOINT ["text-embeddings-router"] |
| 80 | +CMD ["--json-output"] |
| 81 | + |
| 82 | +FROM base AS http |
| 83 | + |
| 84 | +COPY --from=http-builder /usr/src/target/release/text-embeddings-router /usr/local/bin/text-embeddings-router |
| 85 | + |
| 86 | +ENTRYPOINT ["text-embeddings-router"] |
| 87 | +CMD ["--json-output"] |
0 commit comments