Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (48 loc) · 2.62 KB
/
Copy pathDockerfile
File metadata and controls
52 lines (48 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# fastmail-cli as a container. Default command runs the MCP server over HTTP —
# this is the image the mcp-gateway proxies to as a backend (token per request
# via X-Fastmail-Token).
#
# The image holds the release binaries CI built; nothing is compiled here. The
# build context is a directory holding `<arch>/fastmail` for each Docker
# architecture (amd64, arm64), which CI stages from the `linux-build`
# tarballs. To build one locally:
#
# cargo build --release --locked
# mkdir -p dist/amd64 && cp target/release/fastmail dist/amd64/
# docker build --platform linux/amd64 -f Dockerfile dist
# Distroless rather than a distro base: the binary is the only thing this image
# needs to contain, so there is no shell, no package manager and no apt layer.
# It is not `scratch` because three things rule that out, all verified against
# this image:
#
# - /etc/ssl/certs/ca-certificates.crt — reqwest resolves roots through
# rustls-native-certs, which reads the system trust store rather than
# carrying its own. Without it every TLS handshake fails.
# - libstdc++ / libgcc_s / libc — kreuzberg embeds pdfium and dlopens it at
# runtime, so a dynamic loader and the C++ runtime have to be present.
# That extract-and-dlopen is also why a fully static musl build is out.
# - A home the runtime user owns, and a writable /tmp — attachment
# extraction, pdfium included, runs in a worker given a private temp
# directory in the user's cache, falling back to one under /tmp (see
# `isolate` in src/extract.rs for the order and the checks).
#
# glibc invariant: whatever builds the binary must be no newer than this base.
# Symbol versioning is forward-compatible only, so a binary linked against a
# newer glibc builds fine and dies at exec time. cc-debian13 is trixie, 2.41,
# above the ubuntu-24.04 runners CI builds on (2.39). Bumping either end means
# re-checking both. cc-debian12 is 2.36 and would not clear the runners.
#
# The `nonroot` variant runs as uid 65532. The server holds a mail account's
# token for the duration of each request and parses mail from the internet, so
# it gets no root to escalate from. Its home is /home/nonroot, owned by that
# user. Overriding the uid at runtime (Kubernetes `runAsUser`, `docker --user`)
# leaves HOME at `/` for a uid with no passwd entry, so set HOME to a directory
# that uid owns as well.
FROM gcr.io/distroless/cc-debian13:nonroot
ARG TARGETARCH
# Absolute, not a bare name: there is no shell here to fall back on for PATH
# resolution.
COPY ${TARGETARCH}/fastmail /usr/local/bin/fastmail
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/fastmail"]
CMD ["mcp", "--http", "0.0.0.0:8080"]