@@ -2,62 +2,98 @@ name: Build and Push Docker Images
22
33on :
44 push :
5- branches :
6- - main
7- - develop
8- tags :
9- - ' v*'
5+ branches : [main, develop]
6+ tags : ['v*']
107 pull_request :
11- branches :
12- - main
8+ branches : [main]
139 workflow_dispatch :
1410
1511env :
1612 REGISTRY : docker.io
1713 BACKEND_IMAGE_NAME : cyberfly/cyberfly_node
1814
1915jobs :
16+ build-rust-binaries :
17+ runs-on : ubuntu-latest
18+ container : ubuntu:22.04
19+
20+ strategy :
21+ matrix :
22+ include :
23+ - target : x86_64-unknown-linux-gnu
24+ arch : amd64
25+ - target : aarch64-unknown-linux-gnu
26+ arch : arm64
27+
28+ steps :
29+ - uses : actions/checkout@v4
30+
31+ - name : Install deps
32+ run : |
33+ apt-get update
34+ apt-get install -y \
35+ build-essential curl git cmake pkg-config clang \
36+ libssl-dev \
37+ gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
38+
39+ - name : Install Rust
40+ run : |
41+ curl https://sh.rustup.rs -sSf | sh -s -- -y
42+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
43+ rustup target add ${{ matrix.target }}
44+
45+ - name : Build Rust binary (NO jemalloc, NO OpenMP tricks)
46+ run : |
47+ cargo build --release --target ${{ matrix.target }}
48+
49+ - name : Strip binary
50+ run : |
51+ if [ "${{ matrix.arch }}" = "amd64" ]; then
52+ strip target/${{ matrix.target }}/release/cyberfly-rust-node
53+ else
54+ aarch64-linux-gnu-strip target/${{ matrix.target }}/release/cyberfly-rust-node || true
55+ fi
56+
57+ - name : Upload binary
58+ uses : actions/upload-artifact@v4
59+ with :
60+ name : cyberfly-rust-node-${{ matrix.arch }}
61+ path : target/${{ matrix.target }}/release/cyberfly-rust-node
62+
2063 build-and-push :
64+ needs : build-rust-binaries
2165 runs-on : ubuntu-latest
22- permissions :
23- contents : read
24- packages : write
2566
2667 steps :
27- - name : Checkout repository
28- uses : actions/checkout@v4
68+ - uses : actions/checkout@v4
69+
70+ - uses : actions/download-artifact@v4
71+ with :
72+ name : cyberfly-rust-node-amd64
73+ path : .
74+
75+ - uses : actions/download-artifact@v4
76+ with :
77+ name : cyberfly-rust-node-arm64
78+ path : .
2979
30- - name : Set up QEMU
31- uses : docker/setup-qemu-action@v3
80+ # 🔥 Place your prebuilt NO-OpenMP MNN here
81+ - name : Add MNN library
82+ run : |
83+ cp mnn/libMNN.so ./libMNN.so
84+ ls -lah libMNN.so
3285
33- - name : Set up Docker Buildx
34- uses : docker/setup-buildx-action@v3
86+ - uses : docker/setup-qemu-action@v3
87+ - uses : docker/setup-buildx-action@v3
3588
36- - name : Log in to Docker Hub
37- uses : docker/login-action@v3
89+ - uses : docker/login-action@v3
3890 with :
3991 username : ${{ secrets.DOCKER_USERNAME }}
4092 password : ${{ secrets.DOCKER_PASSWORD }}
4193
42- - name : Extract Docker metadata
43- id : meta
44- uses : docker/metadata-action@v5
45- with :
46- images : ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}
47- tags : |
48- type=ref,event=branch
49- type=ref,event=pr
50- type=semver,pattern={{version}}
51- type=semver,pattern={{major}}.{{minor}}
52- type=raw,value=latest,enable={{is_default_branch}}
53-
54- - name : Build and push Docker image
55- uses : docker/build-push-action@v5
94+ - uses : docker/build-push-action@v5
5695 with :
5796 context : .
5897 platforms : linux/amd64,linux/arm64
5998 push : true
60- tags : ${{ steps.meta.outputs.tags }}
61- labels : ${{ steps.meta.outputs.labels }}
62- cache-from : type=gha
63- cache-to : type=gha,mode=max
99+ tags : ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:latest
0 commit comments