31 lines
1.1 KiB
Docker
31 lines
1.1 KiB
Docker
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 cargo chef prepare --recipe-path recipe.json
|
|
|
|
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
|
|
|
|
FROM gcr.io/distroless/cc AS runtime
|
|
|
|
ADD --chmod=a+x vendor/busybox_WGET /usr/bin/wget
|
|
COPY --from=builder /app/target/release/nuchat /usr/bin/
|
|
|
|
# HEALTHCHECK --interval=5s --retries=1 --timeout=5s CMD ["wget", "-q", "--spider", "http://localhost:7000/healthcheck
|
|
|
|
ENTRYPOINT [ "nuchat", "--host", "0.0.0.0" ]
|