mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 19:22:26 +00:00
Dockerfile: Add caching with cargo-chef
This commit is contained in:
19
Dockerfile
19
Dockerfile
@@ -1,10 +1,23 @@
|
||||
FROM rust:1.82-alpine AS builder
|
||||
FROM rust:1.83 AS chef
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y musl-dev musl-tools --no-install-recommends \
|
||||
&& rustup target add x86_64-unknown-linux-musl \
|
||||
&& cargo install cargo-chef --locked \
|
||||
&& rm -rf "$CARGO_HOME/registry"
|
||||
WORKDIR /rustical
|
||||
|
||||
FROM chef AS planner
|
||||
COPY . .
|
||||
RUN cargo chef prepare
|
||||
|
||||
FROM chef AS builder
|
||||
# We need to statically link C dependencies like sqlite, otherwise we get
|
||||
# exec /usr/local/bin/rustical: no such file or directory
|
||||
# x86_64-unknown-linux-musl does static linking by default
|
||||
RUN apk add --no-progress build-base; \
|
||||
rustup target add x86_64-unknown-linux-musl
|
||||
WORKDIR /rustical
|
||||
COPY --from=planner /rustical/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --target x86_64-unknown-linux-musl
|
||||
|
||||
COPY . .
|
||||
RUN --mount=type=cache,target=target cargo install --target x86_64-unknown-linux-musl --path .
|
||||
|
||||
|
||||
Reference in New Issue
Block a user