From 43718f17f32dd1f09f575c9071e8d193802b2d3d Mon Sep 17 00:00:00 2001 From: Zeyad Kenawi Date: Fri, 12 May 2023 15:56:48 +0300 Subject: [PATCH 1/4] fix: remove building when having a tag and use arm64 instead of arm/v8 --- .github/workflows/build-images.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 15708e0..7e417a8 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -2,8 +2,6 @@ name: Build on: push: - tags: - - v* jobs: build: @@ -31,7 +29,7 @@ jobs: uses: docker/build-push-action@v4 with: context: . - platforms: linux/amd64,linux/arm/v8 + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From b5e91acb0b8f7c76ba7364aeb25d035458e68378 Mon Sep 17 00:00:00 2001 From: Zeyad Kenawi Date: Mon, 15 May 2023 16:20:32 +0300 Subject: [PATCH 2/4] feat: use cross compilation for building the docker image. --- Dockerfile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6daea3e..6e3a357 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,10 @@ -FROM rust:1.61-buster as builder +# Needed for rust cross compilation helper scripts. +# https://github.com/tonistiigi/xx#rust +FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx + +FROM --platform=$BUILDPLATFORM rust:1.61-buster as builder + +COPY --from=xx / / WORKDIR /build/mongoproxy @@ -7,11 +13,17 @@ COPY proxy/ ./proxy COPY mongo-protocol/ ./mongo-protocol COPY async-bson/ ./async-bson -RUN cargo build --release +RUN apt-get update && apt-get install -y clang lld + RUN cargo test --release +ARG TARGETPLATFORM + +RUN xx-apt-get install -y xx-c-essentials +RUN xx-cargo build --release --target-dir ./ FROM debian:buster-slim +COPY --from=xx / / RUN apt-get update && apt-get install -y iptables RUN update-alternatives --set iptables /usr/sbin/iptables-legacy @@ -19,7 +31,7 @@ RUN adduser --uid 9999 --disabled-password --gecos '' mongoproxy USER mongoproxy WORKDIR /mongoproxy -COPY --from=builder /build/mongoproxy/target/release/mongoproxy ./ +COPY --from=builder /build/mongoproxy/*/release/mongoproxy ./ COPY iptables-init.sh . ENV MALLOC_ARENA_MAX 2 From cfb152d01312625b737d35f4120b35e939030b2c Mon Sep 17 00:00:00 2001 From: Zeyad Kenawi Date: Mon, 15 May 2023 16:22:45 +0300 Subject: [PATCH 3/4] chore: remove useless COPY --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6e3a357..2bcc27a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,6 @@ RUN xx-cargo build --release --target-dir ./ FROM debian:buster-slim -COPY --from=xx / / RUN apt-get update && apt-get install -y iptables RUN update-alternatives --set iptables /usr/sbin/iptables-legacy From 77755a433e549cf3d235efc49bfc855d1389be6c Mon Sep 17 00:00:00 2001 From: Zeyad Kenawi Date: Tue, 16 May 2023 09:26:15 +0300 Subject: [PATCH 4/4] feat: build on github actions on PR. --- .github/workflows/build-images.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 7e417a8..d12e445 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -2,6 +2,11 @@ name: Build on: push: + tags: + - v* + pull_request: + branches: + - master jobs: build: