-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
28 lines (24 loc) · 881 Bytes
/
Dockerfile
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
ARG RUST_VERSION=1.80.1
FROM rust:${RUST_VERSION}-alpine3.20 AS toolchain
ENV CARGO_BUILD_TARGET="x86_64-unknown-linux-musl"
RUN rustup target add ${CARGO_BUILD_TARGET}
RUN apk add --no-cache musl-dev linux-headers make clang mold
RUN cargo install [email protected]
FROM toolchain AS cacher
WORKDIR /app
COPY ./Cargo.toml ./Cargo.lock ./
COPY ./benches ./benches
RUN cargo chef prepare --recipe-path recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
FROM toolchain AS builder
WORKDIR /app
COPY --from=cacher /app /app
COPY . /app
RUN echo "Cargo target: $CARGO_BUILD_TARGET"
RUN cargo build --release --target $CARGO_BUILD_TARGET
FROM scratch
WORKDIR /app
COPY --from=builder /tmp /tmp
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/nkv-server .
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/nkv-client .
ENTRYPOINT []