Skip to content

Commit

Permalink
docker: util RUN --mount=type=cache...
Browse files Browse the repository at this point in the history
downside is this doesn't play well with

BuildKit's cache-to, cache-from. affecting our ability to push cache to GH

moby/buildkit#1673
  • Loading branch information
miraclx committed Apr 17, 2023
1 parent 96c3ecb commit b2f0147
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
.gitattributes

target/
!target/cache
Dockerfile
.dockerignore
22 changes: 9 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@ RUN apt-get update \
apt-get install --no-install-recommends --assume-yes \
protobuf-compiler libprotobuf-dev
COPY . .
COPY ./targe[t]/cach[e]/us[r]/ /usr/
RUN rm -rf ./target/cache
RUN CARGO_INCREMENTAL=0 cargo build --release --package mpc-recovery

FROM scratch as export-artifacts
COPY --from=builder /usr/src/app/target /usr/src/app/target
COPY --from=builder /usr/local/cargo/bin /usr/local/cargo/bin
COPY --from=builder /usr/local/cargo/git* /usr/local/cargo/git
COPY --from=builder /usr/local/cargo/.crate.toml* /usr/local/cargo/.crate.toml
COPY --from=builder /usr/local/cargo/.crate2.toml* /usr/local/cargo/.crate2.toml
COPY --from=builder /usr/local/cargo/registry/cache /usr/local/cargo/registry/cache
COPY --from=builder /usr/local/cargo/registry/index /usr/local/cargo/registry/index
RUN --mount=type=cache,target=/usr/src/app/target \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/cargo/.crate.toml \
--mount=type=cache,target=/usr/local/cargo/registry/cache \
--mount=type=cache,target=/usr/local/cargo/registry/index \
CARGO_INCREMENTAL=0 cargo build --release --package mpc-recovery \
&& \
cp ./target/release/mpc-recovery /usr/local/bin/mpc-recovery

FROM debian:buster-slim as runtime
RUN apt-get update && apt-get install --assume-yes libssl-dev
COPY --from=builder /usr/src/app/target/release/mpc-recovery /usr/local/bin/mpc-recovery
COPY --from=builder /usr/local/bin/mpc-recovery /usr/local/bin/mpc-recovery
WORKDIR /usr/local/bin

ENTRYPOINT [ "mpc-recovery" ]

0 comments on commit b2f0147

Please sign in to comment.