ZIm/Dockerfile
Marshall Bowers ba5c1322ce
collab: Add missing dependencies for building Docker image (#17893)
This PR adds some missing dependencies to the Docker image that are now
needed in order to build collab.

When trying to build the docker image at
761129e373 it fails with the following
error:

```
985.3   = note: /usr/bin/ld: cannot find -lxkbcommon: No such file or directory
985.3           /usr/bin/ld: cannot find -lxkbcommon-x11: No such file or directory
985.3           collect2: error: ld returned 1 exit status
985.3           
985.3 
985.4 error: could not compile `collab` (bin "collab") due to 1 previous error
```

The last time we built the Docker image for collab was:

- Staging: 4f408ec65a
- Production: fc4c533d0a

Release Notes:

- N/A
2024-09-16 12:40:56 -04:00

55 lines
2 KiB
Docker

# syntax = docker/dockerfile:1.2
FROM rust:1.81-bookworm as builder
WORKDIR app
COPY . .
# Compile collab server
ARG CARGO_PROFILE_RELEASE_PANIC=abort
ARG GITHUB_SHA
ENV GITHUB_SHA=$GITHUB_SHA
# At some point in the past 3 weeks, additional dependencies on `xkbcommon` and
# `xkbcommon-x11` were introduced into collab.
#
# Now when we try to build collab for the Docker image, it fails with the following
# error:
#
# ```
# 985.3 = note: /usr/bin/ld: cannot find -lxkbcommon: No such file or directory
# 985.3 /usr/bin/ld: cannot find -lxkbcommon-x11: No such file or directory
# 985.3 collect2: error: ld returned 1 exit status
# ```
#
# The last successful deploys were at:
# - Staging: `4f408ec65a3867278322a189b4eb20f1ab51f508`
# - Production: `fc4c533d0a8c489e5636a4249d2b52a80039fbd7`
#
# Installing these as a temporary workaround, but I think ideally we'd want to figure
# out what caused them to be included in the first place.
RUN apt-get update; \
apt-get install -y --no-install-recommends libxkbcommon-dev libxkbcommon-x11-dev
RUN --mount=type=cache,target=./script/node_modules \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=./target \
cargo build --release --package collab --bin collab
# Copy collab server binary out of cached directory
RUN --mount=type=cache,target=./target \
cp /app/target/release/collab /app/collab
# Copy collab server binary to the runtime image
FROM debian:bookworm-slim as runtime
RUN apt-get update; \
apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates \
linux-perf binutils
WORKDIR app
COPY --from=builder /app/collab /app/collab
COPY --from=builder /app/crates/collab/migrations /app/migrations
COPY --from=builder /app/crates/collab/migrations_llm /app/migrations_llm
ENV MIGRATIONS_PATH=/app/migrations
ENV LLM_DATABASE_MIGRATIONS_PATH=/app/migrations_llm
ENTRYPOINT ["/app/collab"]