1# syntax = docker/dockerfile:1.2
2
3FROM rust:1.90-bookworm as builder
4WORKDIR app
5COPY . .
6
7# Replace the Cargo configuration with the one used by collab.
8COPY ./.cargo/collab-config.toml ./.cargo/config.toml
9
10# Compile collab server
11ARG CARGO_PROFILE_RELEASE_PANIC=abort
12ARG GITHUB_SHA
13
14ENV GITHUB_SHA=$GITHUB_SHA
15
16# Also add `cmake`, since we need it to build `wasmtime`.
17RUN apt-get update; \
18 apt-get install -y --no-install-recommends cmake
19
20RUN --mount=type=cache,target=./script/node_modules \
21 --mount=type=cache,target=/usr/local/cargo/registry \
22 --mount=type=cache,target=/usr/local/cargo/git \
23 --mount=type=cache,target=./target \
24 cargo build --release --package collab --bin collab
25
26# Copy collab server binary out of cached directory
27RUN --mount=type=cache,target=./target \
28 cp /app/target/release/collab /app/collab
29
30# Copy collab server binary to the runtime image
31FROM debian:bookworm-slim as runtime
32RUN apt-get update; \
33 apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates \
34 linux-perf binutils
35WORKDIR app
36COPY --from=builder /app/collab /app/collab
37COPY --from=builder /app/crates/collab/migrations /app/migrations
38COPY --from=builder /app/crates/collab/migrations_llm /app/migrations_llm
39ENV MIGRATIONS_PATH=/app/migrations
40ENV LLM_DATABASE_MIGRATIONS_PATH=/app/migrations_llm
41ENTRYPOINT ["/app/collab"]