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