From aa8f41af81de5c21e3e53ec04ff2a8a8cd3d35ae Mon Sep 17 00:00:00 2001 From: lennoxlotl Date: Mon, 21 Oct 2024 20:39:34 +0200 Subject: [PATCH] feat: go back to cross because buildx is insanely slow --- .github/workflows/api.yml | 15 +++++++++++++++ api/Dockerfile | 11 +---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 0138955..f66c133 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -26,6 +26,20 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Install cross + run: cargo install cross + - name: Build binary (aarch64) + if: matrix.platform == 'linux/arm64' + run: cross build --target aarch64-unknown-linux-gnu --release + - name: Copy binary (aarch64) + if: matrix.platform == 'linux/arm64' + run: mv target/aarch64-unknown-linux-gnu/release/api api/api + - name: Build binary (amd64) + if: matrix.platform == 'linux/amd64' + run: cargo build --release + - name: Copy binary (amd64) + if: matrix.platform == 'linux/amd64' + run: mv target/release/api api/api - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -46,6 +60,7 @@ jobs: with: push: true platforms: ${{ matrix.platform }} + context: api/ file: api/Dockerfile labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true diff --git a/api/Dockerfile b/api/Dockerfile index c619004..13a4873 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,16 +1,7 @@ -# Build the binary file -FROM rust:1.82.0-bullseye AS builder - -WORKDIR /api -COPY . . - -RUN cargo build --release - -# Run the binary file FROM debian:bullseye-slim WORKDIR /api -COPY --from=builder /api/target/release/api ./api +COPY ./api . RUN apt update && apt install -y ca-certificates