Skip to content

Commit a6b94b3

Browse files
bitwaltclaude
andcommitted
build: KaleidoSwap Docker/CI release tooling + multithreaded runtime
Squash of all KaleidoSwap-specific changes on top of upstream RGB-Tools master, replacing the prior chain of merge commits with a single delta: - .github/workflows/docker.yaml: multi-platform Docker image build/publish - .github/workflows/release.yaml: multi-platform binary release workflow - Dockerfile: multi-stage cargo-chef build (rust 1.95) incl. rust-lightning build context - src/main.rs: multi-threaded tokio runtime Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7597bbd commit a6b94b3

4 files changed

Lines changed: 231 additions & 5 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/rgb-lightning-node
12+
13+
jobs:
14+
build:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- runner: ubuntu-latest
20+
platform: linux/amd64
21+
arch: amd64
22+
- runner: ubuntu-24.04-arm
23+
platform: linux/arm64
24+
arch: arm64
25+
runs-on: ${{ matrix.runner }}
26+
timeout-minutes: 60
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
with:
31+
submodules: recursive
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Login to Docker Hub
37+
uses: docker/login-action@v3
38+
with:
39+
username: ${{ secrets.DOCKERHUB_USERNAME }}
40+
password: ${{ secrets.DOCKERHUB_TOKEN }}
41+
42+
- name: Extract Docker metadata
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.IMAGE_NAME }}
47+
48+
- name: Build and push by digest
49+
id: build
50+
uses: docker/build-push-action@v6
51+
with:
52+
context: .
53+
platforms: ${{ matrix.platform }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
outputs: type=image,"name=${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true
56+
cache-from: type=gha,scope=${{ matrix.arch }}
57+
cache-to: type=gha,scope=${{ matrix.arch }},mode=max
58+
59+
- name: Export digest
60+
run: |
61+
mkdir -p ${{ runner.temp }}/digests
62+
digest="${{ steps.build.outputs.digest }}"
63+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
64+
65+
- name: Upload digest
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: digest-${{ matrix.arch }}
69+
path: ${{ runner.temp }}/digests/*
70+
if-no-files-found: error
71+
retention-days: 1
72+
73+
merge:
74+
runs-on: ubuntu-latest
75+
needs: build
76+
timeout-minutes: 10
77+
steps:
78+
- name: Download digests
79+
uses: actions/download-artifact@v4
80+
with:
81+
path: ${{ runner.temp }}/digests
82+
pattern: digest-*
83+
merge-multiple: true
84+
85+
- name: Login to Docker Hub
86+
uses: docker/login-action@v3
87+
with:
88+
username: ${{ secrets.DOCKERHUB_USERNAME }}
89+
password: ${{ secrets.DOCKERHUB_TOKEN }}
90+
91+
- name: Set up Docker Buildx
92+
uses: docker/setup-buildx-action@v3
93+
94+
- name: Extract Docker metadata
95+
id: meta
96+
uses: docker/metadata-action@v5
97+
with:
98+
images: ${{ env.IMAGE_NAME }}
99+
tags: |
100+
type=raw,value=latest,enable={{is_default_branch}}
101+
type=semver,pattern={{version}}
102+
103+
- name: Create manifest list and push
104+
working-directory: ${{ runner.temp }}/digests
105+
run: |
106+
docker buildx imagetools create \
107+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
108+
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
109+
110+
- name: Inspect image
111+
run: |
112+
docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}"

.github/workflows/release.yaml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
BINARY_NAME: rgb-lightning-node
14+
15+
jobs:
16+
build:
17+
timeout-minutes: 45
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- target: x86_64-unknown-linux-gnu
24+
os: ubuntu-latest
25+
archive: tar.gz
26+
- target: aarch64-unknown-linux-gnu
27+
os: ubuntu-latest
28+
archive: tar.gz
29+
- target: x86_64-apple-darwin
30+
os: macos-latest
31+
archive: tar.gz
32+
- target: aarch64-apple-darwin
33+
os: macos-latest
34+
archive: tar.gz
35+
- target: x86_64-pc-windows-msvc
36+
os: windows-latest
37+
archive: zip
38+
39+
steps:
40+
- uses: ilammy/setup-nasm@v1
41+
42+
- uses: actions/checkout@v4
43+
with:
44+
submodules: true
45+
46+
- uses: actions-rust-lang/setup-rust-toolchain@v1
47+
with:
48+
toolchain: stable
49+
target: ${{ matrix.target }}
50+
rustflags: ""
51+
52+
- name: Install cross-compilation deps (aarch64-linux)
53+
if: matrix.target == 'aarch64-unknown-linux-gnu'
54+
run: |
55+
sudo apt-get update
56+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
57+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
58+
59+
- name: Build
60+
run: cargo build --release --target ${{ matrix.target }}
61+
62+
- name: Package (unix)
63+
if: matrix.archive == 'tar.gz'
64+
run: |
65+
cd target/${{ matrix.target }}/release
66+
tar czf ../../../${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ${{ env.BINARY_NAME }}
67+
68+
- name: Package (windows)
69+
if: matrix.archive == 'zip'
70+
shell: pwsh
71+
run: |
72+
Compress-Archive -Path "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe" -DestinationPath "${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.zip"
73+
74+
- name: Upload artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: ${{ env.BINARY_NAME }}-${{ matrix.target }}
78+
path: ${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.*
79+
80+
release:
81+
needs: build
82+
runs-on: ubuntu-latest
83+
steps:
84+
- name: Download all artifacts
85+
uses: actions/download-artifact@v4
86+
with:
87+
merge-multiple: true
88+
89+
- name: Create release
90+
uses: softprops/action-gh-release@v2
91+
with:
92+
generate_release_notes: true
93+
files: |
94+
${{ env.BINARY_NAME }}-*

Dockerfile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1-
FROM rust:1.95-slim-trixie AS builder
1+
FROM rust:1.95-slim-trixie AS chef
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
pkg-config libssl-dev \
5+
&& rm -rf /var/lib/apt/lists/*
6+
7+
RUN cargo install cargo-chef --locked
8+
9+
WORKDIR /app
10+
11+
12+
FROM chef AS planner
213

314
COPY . .
15+
RUN cargo chef prepare --recipe-path recipe.json
16+
417

18+
FROM chef AS builder
19+
20+
COPY --from=planner /app/recipe.json recipe.json
21+
COPY rust-lightning/ rust-lightning/
22+
RUN cargo chef cook --release --recipe-path recipe.json
23+
24+
COPY . .
525
RUN cargo build --release
626

727

828
FROM debian:trixie-slim
929

10-
COPY --from=builder ./target/release/rgb-lightning-node /usr/bin/rgb-lightning-node
11-
12-
RUN apt-get update && apt install -y --no-install-recommends \
30+
RUN apt-get update && apt-get install -y --no-install-recommends \
1331
ca-certificates openssl \
1432
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1533

34+
COPY --from=builder /app/target/release/rgb-lightning-node /usr/bin/rgb-lightning-node
35+
1636
ENTRYPOINT ["/usr/bin/rgb-lightning-node"]

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use crate::routes::{
5555
};
5656
use crate::utils::{start_daemon, AppState, LOGS_DIR};
5757

58-
#[tokio::main]
58+
#[tokio::main(flavor = "multi_thread", worker_threads = 8)]
5959
async fn main() -> Result<()> {
6060
let args = args::parse_startup_args()?;
6161

0 commit comments

Comments
 (0)