Skip to content

Commit 83691dd

Browse files
author
cyberfly
committed
restore old build method
1 parent 2444b72 commit 83691dd

2 files changed

Lines changed: 88 additions & 103 deletions

File tree

.github/workflows/docker-build-push.yml

Lines changed: 72 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,98 @@ name: Build and Push Docker Images
22

33
on:
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

1511
env:
1612
REGISTRY: docker.io
1713
BACKEND_IMAGE_NAME: cyberfly/cyberfly_node
1814

1915
jobs:
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

Dockerfile

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,7 @@
1-
# =========================
2-
# Stage 1: Build MNN (NO OpenMP)
3-
# =========================
4-
FROM ubuntu:22.04 AS mnn-builder
5-
6-
RUN apt-get update && apt-get install -y \
7-
git cmake build-essential \
8-
ca-certificates \
9-
&& rm -rf /var/lib/apt/lists/*
10-
11-
WORKDIR /build
12-
13-
RUN git clone https://github.com/alibaba/MNN.git
14-
WORKDIR /build/MNN
15-
16-
RUN mkdir build && cd build && \
17-
cmake .. \
18-
-DMNN_USE_OPENMP=OFF \
19-
-DMNN_OPENMP=OFF \
20-
-DMNN_USE_THREAD_POOL=ON \
21-
-DMNN_USE_PTHREADPOOL=ON \
22-
-DMNN_BUILD_SHARED_LIBS=ON \
23-
-DMNN_BUILD_TOOLS=OFF \
24-
-DMNN_BUILD_TEST=OFF \
25-
-DMNN_BUILD_CONVERTER=OFF && \
26-
cmake --build . -j$(nproc) && \
27-
cmake --install .
28-
29-
30-
# =========================
31-
# Stage 2: Build Rust binary
32-
# =========================
33-
FROM ubuntu:22.04 AS rust-builder
34-
35-
RUN apt-get update && apt-get install -y \
36-
build-essential curl pkg-config \
37-
libssl-dev clang cmake \
38-
ca-certificates \
39-
&& rm -rf /var/lib/apt/lists/*
40-
41-
# Copy MNN (NO OpenMP)
42-
COPY --from=mnn-builder /usr/local /usr/local
43-
44-
ENV MNN_DIR=/usr/local
45-
ENV LD_LIBRARY_PATH=/usr/local/lib
46-
47-
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
48-
ENV PATH="/root/.cargo/bin:${PATH}"
49-
50-
WORKDIR /build
51-
COPY Cargo.toml ./
52-
COPY src ./src
53-
COPY schema.graphql ./
54-
55-
RUN cargo build --release
56-
57-
58-
# =========================
59-
# Stage 3: Runtime
60-
# =========================
611
FROM ubuntu:22.04
622

63-
RUN apt-get update && apt-get install -y \
3+
RUN apt-get update && \
4+
apt-get install -y --no-install-recommends \
645
ca-certificates \
656
libssl3 \
667
libstdc++6 \
@@ -69,23 +10,31 @@ RUN apt-get update && apt-get install -y \
6910
WORKDIR /app
7011
RUN mkdir -p /app/data/iroh/models
7112

72-
COPY --from=rust-builder /usr/local /usr/local
73-
COPY --from=rust-builder /build/target/release/cyberfly-rust-node /app/cyberfly-rust-node
13+
# Copy Rust binary
14+
ARG TARGETARCH
15+
COPY cyberfly-rust-node-${TARGETARCH} /app/cyberfly-rust-node
16+
17+
# Copy schema
7418
COPY schema.graphql /app/schema.graphql
7519

20+
# 🔥 Copy NO-OpenMP MNN (THIS IS THE FIX)
21+
COPY libMNN.so /usr/local/lib/libMNN.so
7622
ENV LD_LIBRARY_PATH=/usr/local/lib
77-
ENV MNN_USE_OPENMP=0
23+
24+
RUN chmod +x /app/cyberfly-rust-node
25+
26+
# ===== Runtime safety =====
7827
ENV MNN_BACKEND=cpu
7928
ENV MNN_DISABLE_GPU=1
29+
ENV MNN_USE_OPENMP=0
30+
8031
ENV OMP_NUM_THREADS=1
81-
ENV OMP_WAIT_POLICY=PASSIVE
8232
ENV KMP_AFFINITY=disabled
8333
ENV GOMP_CPU_AFFINITY=0
8434
ENV MALLOC_ARENA_MAX=1
8535
ENV LD_PRELOAD=
86-
ENV SLED_CACHE_MB=256
8736

88-
RUN chmod +x /app/cyberfly-rust-node
37+
ENV SLED_CACHE_MB=256
8938

9039
EXPOSE 31001 31002 31003 31006
9140

0 commit comments

Comments
 (0)