From 5131c5e570f79f46b21f705baf8e6446200b7bad Mon Sep 17 00:00:00 2001 From: Sergio <77530549+sergi0g@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:08:58 +0300 Subject: [PATCH] Optimize docker build workflow --- .github/workflows/build.yml | 4 +++- Dockerfile | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f40f171..1a6a1e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,4 +33,6 @@ jobs: context: . push: true platforms: linux/amd64,linux/arm64 - tags: ghcr.io/sergi0g/cup:latest \ No newline at end of file + tags: ghcr.io/sergi0g/cup:latest + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 0c0c405..ad6b39e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ FROM rust:alpine AS build -WORKDIR /cup - RUN apk add musl-dev -COPY src src -COPY Cargo.toml . -COPY Cargo.lock . - +RUN cargo new cup +WORKDIR /cup +COPY Cargo.toml Cargo.lock . RUN cargo build --release +COPY src ./src +RUN cargo install --path . + FROM scratch -COPY --from=build /cup/target/release/cup /cup +COPY --from=build /usr/local/cargo/bin/cup /cup ENTRYPOINT ["/cup"] \ No newline at end of file