From d66ff6b23a9134613b4c30c472550202f086e041 Mon Sep 17 00:00:00 2001 From: Ben Eggers Date: Fri, 22 Mar 2024 15:55:40 -0700 Subject: [PATCH] Rust worker now rebuilds in ~53s on my machine --- rust/worker/.dockerignore | 3 +++ rust/worker/Dockerfile | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 rust/worker/.dockerignore diff --git a/rust/worker/.dockerignore b/rust/worker/.dockerignore new file mode 100644 index 00000000000..2f0f51534e8 --- /dev/null +++ b/rust/worker/.dockerignore @@ -0,0 +1,3 @@ +.dockerignore +.gitignore +Dockerfile \ No newline at end of file diff --git a/rust/worker/Dockerfile b/rust/worker/Dockerfile index 93a6a14214e..00caf8c5f9d 100644 --- a/rust/worker/Dockerfile +++ b/rust/worker/Dockerfile @@ -1,20 +1,34 @@ FROM rust:1.74.1 as builder ARG CHROMA_KUBERNETES_INTEGRATION=0 -ARG RELEASE_MODE=0 ENV CHROMA_KUBERNETES_INTEGRATION $CHROMA_KUBERNETES_INTEGRATION +ARG RELEASE_MODE= + WORKDIR / RUN git clone https://github.com/chroma-core/hnswlib.git +# Cache dependencies by building them without our code first. +# https://dev.to/rogertorres/first-steps-with-docker-rust-30oi +# https://www.reddit.com/r/rust/comments/126xeyx/exploring_the_problem_of_faster_cargo_docker/ WORKDIR /chroma/ -COPY . . - +COPY Cargo.toml Cargo.toml +COPY Cargo.lock CARGO.lock +COPY idl/ idl/ +COPY /rust/worker/Cargo.toml rust/worker/Cargo.toml ENV PROTOC_ZIP=protoc-25.1-linux-x86_64.zip RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v25.1/$PROTOC_ZIP \ && unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \ && unzip -o $PROTOC_ZIP -d /usr/local 'include/*' \ && rm -f $PROTOC_ZIP +# We need to replace the query node's real main() with a dummy at the expected location. +RUN mkdir -p rust/worker/src/bin/ && echo "fn main() {}" > rust/worker/src/bin/query_service.rs RUN if [ "$RELEASE_MODE" = "1" ]; then cargo build --release; else cargo build; fi +RUN rm -f rust/worker/src/bin/query_service.rs + +COPY rust/ rust/ +RUN touch rust/worker/src/bin/query_service.rs +RUN if [ "$RELEASE_MODE" = "1" ]; then cargo install --path rust/worker; else cargo install --debug --path rust/worker; fi +COPY rust/worker/chroma_config.yaml . -CMD ["./target/release/query_service"] +CMD ["query_service"] \ No newline at end of file