From 9e868a2eb045a847899dfdd46f7bbe90418e12d2 Mon Sep 17 00:00:00 2001 From: Luc Date: Sat, 20 May 2023 04:33:36 +0000 Subject: [PATCH] Bump Dockerfile & Build process --- .github/.deploy/Dockerfile | 26 +++++++++++++++++++++++++- .github/workflows/build.yml | 24 ++---------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/.github/.deploy/Dockerfile b/.github/.deploy/Dockerfile index ddfbae7..4c19d61 100644 --- a/.github/.deploy/Dockerfile +++ b/.github/.deploy/Dockerfile @@ -1,3 +1,27 @@ +#################################################################################################### +## Base image +#################################################################################################### +FROM rust:latest AS builder + +RUN update-ca-certificates + +WORKDIR /enstate + +COPY ./Cargo.toml . +COPY ./Cargo.lock . + +RUN mkdir ./src && echo 'fn main() { println!("Dummy!"); }' > ./src/main.rs + +RUN cargo build --release + +RUN rm -rf ./src + +COPY build.rs build.rs +COPY src src +COPY .git .git + +RUN cargo build --release + #################################################################################################### ## Final image #################################################################################################### @@ -6,6 +30,6 @@ FROM gcr.io/distroless/cc WORKDIR /enstate # Copy our build -COPY ./enstate ./ +COPY --from=builder /enstate/target/release/enstate /enstate/enstate CMD ["/enstate/enstate"] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3057167..c2622e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,28 +35,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up cargo cache - uses: actions/cache@v3 - continue-on-error: false - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo- - - - name: Build - run: cargo build --release - - - name: Create .dockerignore - run: echo 'target' > .dockerignore - - - name: Move the binary to the root - run: mv target/release/enstate . - - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -66,3 +44,5 @@ jobs: labels: ${{ steps.meta.outputs.labels }} file: .github/.deploy/Dockerfile context: . + cache-from: type=registry,ref=ghcr.io/v3xlabs/enstate:edge + cache-to: type=inline