···11-FROM rust:1.78-alpine AS builder
11+FROM rust:1.89-alpine AS chef
22+RUN apk add libressl-dev musl-dev sqlite-dev
33+RUN cargo install cargo-chef
2433-# TODO: Figure out what we need to change here!
55+WORKDIR /app
66+FROM chef AS planner
77+# Assumes . is root of monorepo, so build context should be set accordingly
88+COPY . .
99+RUN cargo chef prepare --recipe-path recipe.json
41055-RUN apk add libressl-dev musl-dev sqlite-dev
66-77-WORKDIR /usr/src/unravel
1111+FROM chef AS builder
1212+COPY --from=planner /app/recipe.json recipe.json
1313+# Build dependencies - this is the caching Docker layer!
1414+RUN cargo chef cook --release --recipe-path recipe.json
1515+# Build application. Again, assumes . is root of monorepo.
816COPY . .
99-# TODO: Use cargo-chef to cache dependencies compilation independently of the binary
1010-RUN --mount=type=cache,target=/usr/local/cargo/registry \
1111- --mount=type=cache,target=/root/target \
1212- cargo build --release --package drainpipe && \
1313- # Move the release binary to a folder to be copied to the final image. It can't be copied directly from the target folder because it's in a cache mount
1414- # See https://gist.github.com/noelbundick/6922d26667616e2ba5c3aff59f0824cd?permalink_comment_id=4379948#gistcomment-4379948
1515- mv ./target/release /root
1717+RUN cargo build --release --bin drainpipe
16181719FROM alpine:3.14
1818-COPY --from=builder /root/release/drainpipe /
2020+WORKDIR /app
2121+COPY --from=builder /app/target/release/drainpipe /usr/local/drainpipe
19222023ENV STORE_LOCATION="/drainpipedata/sled"
21242222-ENTRYPOINT ["/drainpipe"]
2525+ENTRYPOINT ["/usr/local/drainpipe"]