Skip to content

Commit

Permalink
Add cache to cargo build
Browse files Browse the repository at this point in the history
  • Loading branch information
simon511000 committed Sep 3, 2023
1 parent 10c270c commit b8e9fa1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ FROM rust:1-alpine3.17 as builder

RUN apk add musl-dev

WORKDIR /usr/src/grandmondebot
RUN cargo new /app/grandmondebot
COPY ./Cargo.toml ./Cargo.lock /app/grandmondebot/

WORKDIR /app/grandmondebot

RUN --mount=type=cache,target=/usr/local/cargo/registry cargo build --release

COPY . .

RUN cargo install --path .
RUN --mount=type=cache,target=/usr/local/cargo/registry cargo build --release

# ========= Stage 2: Production ========= #
FROM alpine as production
Expand All @@ -16,6 +21,6 @@ RUN apk add docker

WORKDIR /app

COPY --from=builder /usr/local/cargo/bin/grandmondebot /app/grandmondebot
COPY --from=builder /app/grandmondebot/target/release/grandmondebot /app/grandmondebot

CMD ./grandmondebot

0 comments on commit b8e9fa1

Please sign in to comment.