-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathDockerfile.api
More file actions
50 lines (38 loc) · 1.3 KB
/
Copy pathDockerfile.api
File metadata and controls
50 lines (38 loc) · 1.3 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
# Build and run the termy-api server (crates/api).
# Migrations are embedded in the binary via sqlx::migrate! and run on startup.
#
# The full Termy workspace pulls GPUI (a git dependency on the Zed repo) just
# to resolve the lockfile, so this build synthesizes a minimal workspace that
# contains only crates/api.
#
# Build: docker build -f Dockerfile.api -t termy-api .
# Run: docker run -p 8080:8080 -e DATABASE_URL=... -e TERMY_API_SECRET=... termy-api
# Builder and runtime must share the same Debian release, or the binary links
# against a newer glibc than the runtime ships.
FROM rust:1.96-bookworm AS builder
WORKDIR /build
COPY crates/api ./crates/api
RUN cat > Cargo.toml <<'EOF'
[workspace]
members = ["crates/api"]
resolver = "2"
[workspace.dependencies]
anyhow = "1.0"
serde_json = "1.0"
[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(macos_sdk_26)',
'cfg(feature, values("cargo-clippy"))',
] }
[workspace.lints.clippy]
EOF
RUN cargo build --release -p termy_api
FROM debian:bookworm-slim AS runtime
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /build/target/release/termy-api /usr/local/bin/termy-api
ENV PORT=8080
EXPOSE 8080
USER nobody
ENTRYPOINT ["termy-api"]