Dockerfile

 1# syntax = docker/dockerfile:1.2
 2
 3FROM rust:1.76-bullseye 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
12RUN --mount=type=cache,target=./script/node_modules \
13    --mount=type=cache,target=/usr/local/cargo/registry \
14    --mount=type=cache,target=./target \
15    cargo build --release --package collab --bin collab
16
17# Copy collab server binary out of cached directory
18RUN --mount=type=cache,target=./target \
19    cp /app/target/release/collab /app/collab
20
21# Copy collab server binary to the runtime image
22FROM debian:bullseye-slim as runtime
23RUN apt-get update; \
24    apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates
25WORKDIR app
26COPY --from=builder /app/collab /app/collab
27COPY --from=builder /app/crates/collab/migrations /app/migrations
28ENV MIGRATIONS_PATH=/app/migrations
29ENTRYPOINT ["/app/collab"]