Update Rust build system: use rustup with musl target for static builds
This commit is contained in:
@@ -43,7 +43,14 @@ RUN apk add --no-cache \
|
|||||||
grep \
|
grep \
|
||||||
findutils \
|
findutils \
|
||||||
# JSON processing for GitHub API
|
# JSON processing for GitHub API
|
||||||
jq
|
jq \
|
||||||
|
# Rustup for proper Rust musl builds
|
||||||
|
rustup
|
||||||
|
|
||||||
|
# Setup Rust toolchain for musl builds
|
||||||
|
RUN rustup-init -y --default-toolchain stable && \
|
||||||
|
. ~/.cargo/env && \
|
||||||
|
rustup target add x86_64-unknown-linux-musl
|
||||||
|
|
||||||
# Create directories
|
# Create directories
|
||||||
RUN mkdir -p /build/initramfs /build/kernel /build/output /build/github /build/configs/zinit /mnt/zinit
|
RUN mkdir -p /build/initramfs /build/kernel /build/output /build/github /build/configs/zinit /mnt/zinit
|
||||||
|
|||||||
@@ -33,10 +33,15 @@ RUN apk add --no-cache \
|
|||||||
grep \
|
grep \
|
||||||
findutils \
|
findutils \
|
||||||
jq \
|
jq \
|
||||||
# Go and Rust for source compilation
|
# Go for source compilation
|
||||||
go \
|
go \
|
||||||
rust \
|
# Rustup for proper Rust musl builds
|
||||||
cargo
|
rustup
|
||||||
|
|
||||||
|
# Setup Rust toolchain for musl builds
|
||||||
|
RUN rustup-init -y --default-toolchain stable && \
|
||||||
|
. ~/.cargo/env && \
|
||||||
|
rustup target add x86_64-unknown-linux-musl
|
||||||
|
|
||||||
# Create standard directories
|
# Create standard directories
|
||||||
RUN mkdir -p /build/initramfs /build/kernel /build/output /build/github /build/configs/zinit /mnt/zinit /build/source /build/cache
|
RUN mkdir -p /build/initramfs /build/kernel /build/output /build/github /build/configs/zinit /mnt/zinit /build/source /build/cache
|
||||||
|
|||||||
@@ -51,29 +51,21 @@ build_rust_component() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Build the project
|
# Build the project
|
||||||
echo " Compiling with cargo..."
|
echo " Compiling with cargo for musl target..."
|
||||||
if command -v cargo >/dev/null; then
|
|
||||||
cargo build --release
|
# Source cargo environment
|
||||||
|
. ~/.cargo/env
|
||||||
# Install binary to Alpine root
|
|
||||||
mkdir -p "$ALPINE_ROOT$install_path"
|
# Build with musl target for static linking
|
||||||
cp "target/release/$binary_name" "$ALPINE_ROOT$install_path/"
|
cargo build --release --target x86_64-unknown-linux-musl
|
||||||
chmod +x "$ALPINE_ROOT$install_path/$binary_name"
|
|
||||||
|
# Install binary to Alpine root
|
||||||
echo " Success: $install_path/$binary_name installed to Alpine root"
|
mkdir -p "$ALPINE_ROOT$install_path"
|
||||||
return 0
|
cp "target/x86_64-unknown-linux-musl/release/$binary_name" "$ALPINE_ROOT$install_path/"
|
||||||
else
|
chmod +x "$ALPINE_ROOT$install_path/$binary_name"
|
||||||
echo " Error: cargo not found - installing Rust..."
|
|
||||||
apk add --no-cache rust cargo
|
echo " Success: $install_path/$binary_name installed to Alpine root (musl static)"
|
||||||
cargo build --release
|
return 0
|
||||||
|
|
||||||
mkdir -p "$ALPINE_ROOT$install_path"
|
|
||||||
cp "target/release/$binary_name" "$ALPINE_ROOT$install_path/"
|
|
||||||
chmod +x "$ALPINE_ROOT$install_path/$binary_name"
|
|
||||||
|
|
||||||
echo " Success: $install_path/$binary_name installed to Alpine root"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to build Go project from submodule
|
# Function to build Go project from submodule
|
||||||
|
|||||||
Reference in New Issue
Block a user