Skip to content

Commit

Permalink
Rust worker now rebuilds in ~53s on my machine
Browse files Browse the repository at this point in the history
  • Loading branch information
beggers committed Mar 22, 2024
1 parent 08f23d2 commit d66ff6b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions rust/worker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dockerignore
.gitignore
Dockerfile
22 changes: 18 additions & 4 deletions rust/worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit d66ff6b

Please sign in to comment.