Dockerfile

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