From 62921644ae8c0a434a5b0cc015db0ce03c3e7e2d Mon Sep 17 00:00:00 2001 From: Walter Oggioni Date: Tue, 25 Jun 2024 09:04:29 +0800 Subject: [PATCH] single multiplatform build for shadowsockets-rust --- .gitea/workflows/build-shadowsocks-rust.yaml | 27 +++++--------------- shadowsocks-rust/Dockerfile | 12 ++++++--- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.gitea/workflows/build-shadowsocks-rust.yaml b/.gitea/workflows/build-shadowsocks-rust.yaml index 63f39ff..182208d 100644 --- a/.gitea/workflows/build-shadowsocks-rust.yaml +++ b/.gitea/workflows/build-shadowsocks-rust.yaml @@ -22,33 +22,18 @@ jobs: username: woggioni password: ${{ secrets.PUBLISHER_TOKEN }} - - name: Build and push sserver-rust amd64 image - uses: docker/build-push-action@v5.3.0 + name: Build and push sserver-rust images + uses: docker/build-push-action@v6 with: context: "{{defaultContext}}:shadowsocks-rust" - platforms: linux/amd64 + platforms: | + linux/amd64 + linux/arm64 push: true tags: | "gitea.woggioni.net/woggioni/sserver-rust:latest" "gitea.woggioni.net/woggioni/sserver-rust:v1.20.1" - build-args: | - "TARGETARCH=amd64" - "VERSION=1.20.1" - cache-from: type=registry,ref=gitea.woggioni.net/woggioni/sserver-rust:buildx - cache-to: type=registry,mode=max,compression=zstd,image-manifest=true,oci-mediatypes=true,ref=gitea.woggioni.net/woggioni/sserver-rust:buildx - - - name: Build and push sserver-rust arm64 image - uses: docker/build-push-action@v5.3.0 - with: - context: "{{defaultContext}}:shadowsocks-rust" - platforms: linux/arm64 - push: true - tags: | - "gitea.woggioni.net/woggioni/sserver-rust:latest" - "gitea.woggioni.net/woggioni/sserver-rust:v1.20.1" - build-args: | - "TARGETARCH=arm64" - "VERSION=1.20.1" + build-args: "VERSION=1.20.1" cache-from: type=registry,ref=gitea.woggioni.net/woggioni/sserver-rust:buildx cache-to: type=registry,mode=max,compression=zstd,image-manifest=true,oci-mediatypes=true,ref=gitea.woggioni.net/woggioni/sserver-rust:buildx diff --git a/shadowsocks-rust/Dockerfile b/shadowsocks-rust/Dockerfile index 814eb59..20be851 100644 --- a/shadowsocks-rust/Dockerfile +++ b/shadowsocks-rust/Dockerfile @@ -1,6 +1,6 @@ -FROM --platform=$BUILDPLATFORM rust:alpine3.20 AS builder +FROM --platform=$TARGETPLATFORM rust:alpine AS builder -ARG TARGETARCH VERSION +ARG VERSION TARGETPLATFORM RUN set -x \ && apk add --no-cache build-base cmake llvm15-dev clang15-libclang clang15 rust-bindgen git @@ -9,7 +9,7 @@ WORKDIR /root/shadowsocks-rust RUN git clone --depth 1 --branch "v${VERSION}" https://github.com/shadowsocks/shadowsocks-rust.git . -RUN case "$TARGETARCH" in \ +RUN case "$TARGETPLATFORM" in \ "386") \ RUST_TARGET="i686-unknown-linux-musl" \ MUSL="i686-linux-musl" \ @@ -22,8 +22,12 @@ RUN case "$TARGETARCH" in \ RUST_TARGET="aarch64-unknown-linux-musl" \ MUSL="aarch64-linux-musl" \ ;; \ + "linux/arm/v7") \ + RUST_TARGET="arm-unknown-linux-musleabihf" \ + MUSL="arm-linux-musleabihf" \ + ;; \ *) \ - echo "Doesn't support $TARGETARCH architecture" \ + echo "Doesn't support $TARGETPLATFORM architecture" \ exit 1 \ ;; \ esac \