From e968020e9f9aaa965cf2de0a126e0e30f786d733 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Mon, 5 Feb 2024 15:59:43 +0000 Subject: [PATCH] Add docker build optimizations --- .github/workflows/docker.yml | 13 +++++++++++++ Dockerfile | 12 ++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2544ee3..b9d5191 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,6 +23,17 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Log in to the Container registry uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 with: @@ -44,3 +55,5 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index 6659127..28f241e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM rust:1.67.0 +# Build Stage +FROM rust:1.67.0 AS builder RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends clang cmake build-essential @@ -8,4 +9,11 @@ COPY . . RUN cargo build --release -ENTRYPOINT ["/bin/bash", "-c", "./target/release/mutinynet-faucet-rs ${FLAGS}"] +# Run Stage +FROM debian:buster-slim + +WORKDIR /app + +COPY --from=builder /app/target/release/mutinynet-faucet-rs /app/mutinynet-faucet-rs + +ENTRYPOINT ["/bin/bash", "-c", "./mutinynet-faucet-rs ${FLAGS}"] \ No newline at end of file