From 08782bc53040d05dd6f98b6fbcb223c35f904c56 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Tue, 29 Oct 2024 12:22:50 +0100 Subject: [PATCH] ci/dev: add multi-platform image build (#17) --- .github/workflows/dev.yml | 59 ++++++++++++++++++++++----------------- baresip/Dockerfile | 2 +- libre/Dockerfile | 2 +- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 6951290..360a883 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -26,6 +26,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log into registry uses: docker/login-action@v3 with: @@ -33,18 +39,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build - run: | - docker build libre -t libre-dev \ - --build-arg VERSION=${{ env.VERSION_RE }} - - - name: Tag and Push image - if: github.event_name != 'pull_request' - run: | - docker tag libre-dev ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION_RE }} - docker tag libre-dev ghcr.io/${{ env.IMAGE_NAME }}:latest - docker push ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION_RE }} - docker push ghcr.io/${{ env.IMAGE_NAME }}:latest + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: libre + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION_RE }} + ghcr.io/${{ env.IMAGE_NAME }}:latest + build-args: VERSION=${{ env.VERSION_RE }} baresip-dev: env: @@ -53,6 +57,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log into registry uses: docker/login-action@v3 with: @@ -60,16 +70,15 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build - run: | - docker build baresip -t baresip-dev \ - --build-arg VERSION=${{ env.VERSION_BARESIP }} \ - --build-arg IMAGE=ghcr.io/baresip/docker/libre-dev:latest - - - name: Tag and Push image - if: github.event_name != 'pull_request' - run: | - docker tag baresip-dev ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION_BARESIP }} - docker tag baresip-dev ghcr.io/${{ env.IMAGE_NAME }}:latest - docker push ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION_BARESIP }} - docker push ghcr.io/${{ env.IMAGE_NAME }}:latest + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: baresip + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION_BARESIP }} + ghcr.io/${{ env.IMAGE_NAME }}:latest + build-args: | + VERSION=${{ env.VERSION_BARESIP }} + IMAGE=ghcr.io/baresip/docker/libre-dev:latest diff --git a/baresip/Dockerfile b/baresip/Dockerfile index afb9e8a..3ecf2df 100644 --- a/baresip/Dockerfile +++ b/baresip/Dockerfile @@ -7,7 +7,7 @@ RUN git clone -b ${VERSION} --depth=1 https://github.com/baresip/baresip.git && cd baresip && \ cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-g" -DCMAKE_CXX_FLAGS="-g" -DCMAKE_C_COMPILER=clang-15 \ -DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_INSTALL_PREFIX=/usr && \ - cmake --build build -j && \ + cmake --build build -j4 && \ cmake --install build --prefix dist && cp -a dist/* /usr/ RUN mkdir -p /root/dist/usr && \ cp -a /root/re/dist/* /root/dist/usr/ && \ diff --git a/libre/Dockerfile b/libre/Dockerfile index 38e2e6b..820649f 100644 --- a/libre/Dockerfile +++ b/libre/Dockerfile @@ -5,5 +5,5 @@ RUN install_packages clang-15 make cmake pkg-config git libssl-dev wget ca-certi git clone -b ${VERSION} --depth=1 https://github.com/baresip/re.git && \ cd re && \ cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-g" -DCMAKE_C_COMPILER=clang-15 -DCMAKE_CXX_COMPILER=clang++-15 && \ - cmake --build build -j && \ + cmake --build build -j4 && \ cmake --install build --prefix dist && cp -a dist/* /usr/