swap backend to rust

This commit is contained in:
2025-07-16 16:43:24 +01:00
parent a674f5641d
commit 7dc46b6ad0
16 changed files with 2191 additions and 42 deletions

View File

@ -1,13 +1,27 @@
FROM golang:1.24-alpine AS build
FROM rust:1.87 AS base
RUN cargo install --locked cargo-chef sccache
ENV RUSTC_WRAPPER=sccache SCCACHE_DIR=/sccache
FROM base AS planner
WORKDIR /app
COPY . .
RUN go build -o nuchat fergus.molloy.xyz/nuchat
RUN cargo chef prepare --recipe-path recipe.json
FROM scratch
FROM base AS builder
WORKDIR /app
COPY --from=planner /app/recipe.json recipe.json
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo build --release --bin nuchat --target-dir=/app/target
COPY --from=build /app/nuchat .
FROM gcr.io/distroless/cc AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/nuchat ./nuchat
ENTRYPOINT ["/app/nuchat"]
ENTRYPOINT [ "./nuchat", "--host 0.0.0.0" ]