Add Rust core build step to Dockerfiles (#1473)

This commit is contained in:
Leendert de Borst
2026-01-21 17:29:02 +01:00
parent dd9d33cd69
commit 660cc15acb
3 changed files with 61 additions and 34 deletions

View File

@@ -4,17 +4,27 @@ WORKDIR /app
# ============================================
# Stage: Build core libraries
# ============================================
FROM node:20-slim AS core-builder
FROM rust:1-slim-bookworm AS core-builder
# Install Node.js and wasm-pack (Rust already included in base image)
RUN apt-get update && \
apt-get install -y --no-install-recommends curl ca-certificates && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
rustup target add wasm32-unknown-unknown && \
cargo install wasm-pack --locked && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy core library source files
COPY core/ ./core/
# Build core libraries
# Build core libraries (only browser target needed for Blazor WASM client)
RUN cd ./core && \
chmod +x build-and-distribute.sh && \
./build-and-distribute.sh
./build-and-distribute.sh --browser
# ============================================
# Stage: Build .NET application

View File

@@ -104,39 +104,46 @@ if $BUILD_COMMON; then
echo ""
fi
# Rust core build (optional - requires Rust toolchain)
# Rust core build (required when any platform target is specified)
if $BUILD_BROWSER || $BUILD_DOTNET || $BUILD_IOS || $BUILD_ANDROID; then
cd ./rust
if command -v rustc &> /dev/null; then
echo "📦 Building Rust core..."
if $BUILD_ANDROID; then
echo " → Building for Android..."
./build.sh --android
fi
if $BUILD_IOS; then
echo " → Building for iOS..."
./build.sh --ios
fi
if $BUILD_BROWSER; then
echo " → Building for Browser/WASM..."
./build.sh --browser
fi
if $BUILD_DOTNET; then
echo " → Building for .NET..."
./build.sh --dotnet
fi
echo "✅ Rust core built"
else
echo "⚠️ Skipping Rust core build (Rust not installed)"
echo " Install Rust from https://rustup.rs to enable Rust core builds"
if ! command -v rustc &> /dev/null; then
echo "❌ ERROR: Rust toolchain is required but not installed"
echo " Install Rust from https://rustup.rs"
echo ""
echo " Requested targets require Rust:"
$BUILD_BROWSER && echo " - Browser/WASM"
$BUILD_DOTNET && echo " - .NET"
$BUILD_IOS && echo " - iOS"
$BUILD_ANDROID && echo " - Android"
exit 1
fi
echo "📦 Building Rust core..."
if $BUILD_ANDROID; then
echo " → Building for Android..."
./build.sh --android
fi
if $BUILD_IOS; then
echo " → Building for iOS..."
./build.sh --ios
fi
if $BUILD_BROWSER; then
echo " → Building for Browser/WASM..."
./build.sh --browser
fi
if $BUILD_DOTNET; then
echo " → Building for .NET..."
./build.sh --dotnet
fi
echo "✅ Rust core built"
cd ..
fi

View File

@@ -3,17 +3,27 @@
# ============================================
# Stage 1: Build core libraries
# ============================================
FROM node:20-slim AS core-builder
FROM rust:1-slim-bookworm AS core-builder
# Install Node.js and wasm-pack (Rust already included in base image)
RUN apt-get update && \
apt-get install -y --no-install-recommends curl ca-certificates && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
rustup target add wasm32-unknown-unknown && \
cargo install wasm-pack --locked && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy core library source files
COPY core/ ./core/
# Build core libraries
# Build core libraries (only browser target needed for server apps)
RUN cd ./core && \
chmod +x build-and-distribute.sh && \
./build-and-distribute.sh
./build-and-distribute.sh --browser
# ============================================
# Stage 2: Build .NET applications