Dockerfile-collab

 1# syntax = docker/dockerfile:1.2
 2
 3FROM rust:1.93-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`.
17# clang is needed because `webrtc-sys` uses Clang-specific compiler flags.
18RUN apt-get update; \
19    apt-get install -y --no-install-recommends cmake clang
20
21ENV CC=clang
22ENV CXX=clang++
23
24RUN --mount=type=cache,target=./script/node_modules \
25    --mount=type=cache,target=/usr/local/cargo/registry \
26    --mount=type=cache,target=/usr/local/cargo/git \
27    --mount=type=cache,target=./target \
28    cargo build --release --package collab --bin collab
29
30# Copy collab server binary out of cached directory
31RUN --mount=type=cache,target=./target \
32    cp /app/target/release/collab /app/collab
33
34# Copy collab server binary to the runtime image
35FROM debian:bookworm-slim as runtime
36RUN apt-get update; \
37    apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates \
38    linux-perf binutils
39WORKDIR app
40COPY --from=builder /app/collab /app/collab
41ENTRYPOINT ["/app/collab"]