Dockerfile-collab

 1# syntax = docker/dockerfile:1.2
 2
 3FROM rust:1.81-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# At some point in the past 3 weeks, additional dependencies on `xkbcommon` and
17# `xkbcommon-x11` were introduced into collab.
18#
19# A `git bisect` points to this commit as being the culprit: `b8e6098f60e5dabe98fe8281f993858dacc04a55`.
20#
21# Now when we try to build collab for the Docker image, it fails with the following
22# error:
23#
24# ```
25# 985.3   = note: /usr/bin/ld: cannot find -lxkbcommon: No such file or directory
26# 985.3           /usr/bin/ld: cannot find -lxkbcommon-x11: No such file or directory
27# 985.3           collect2: error: ld returned 1 exit status
28# ```
29#
30# The last successful deploys were at:
31# - Staging: `4f408ec65a3867278322a189b4eb20f1ab51f508`
32# - Production: `fc4c533d0a8c489e5636a4249d2b52a80039fbd7`
33#
34# Installing these as a temporary workaround, but I think ideally we'd want to figure
35# out what caused them to be included in the first place.
36RUN apt-get update; \
37    apt-get install -y --no-install-recommends libxkbcommon-dev libxkbcommon-x11-dev
38
39RUN --mount=type=cache,target=./script/node_modules \
40    --mount=type=cache,target=/usr/local/cargo/registry \
41    --mount=type=cache,target=/usr/local/cargo/git \
42    --mount=type=cache,target=./target \
43    cargo build --release --package collab --bin collab
44
45# Copy collab server binary out of cached directory
46RUN --mount=type=cache,target=./target \
47    cp /app/target/release/collab /app/collab
48
49# Copy collab server binary to the runtime image
50FROM debian:bookworm-slim as runtime
51RUN apt-get update; \
52    apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates \
53    linux-perf binutils
54WORKDIR app
55COPY --from=builder /app/collab /app/collab
56COPY --from=builder /app/crates/collab/migrations /app/migrations
57COPY --from=builder /app/crates/collab/migrations_llm /app/migrations_llm
58ENV MIGRATIONS_PATH=/app/migrations
59ENV LLM_DATABASE_MIGRATIONS_PATH=/app/migrations_llm
60ENTRYPOINT ["/app/collab"]