# BEX Engine — Portable Build Container # Produces binaries compatible with GLIBC 2.31+ (Ubuntu 20.04+, Debian 11+) # # Usage: # docker build -t bex-builder . # docker run --rm -v $(pwd)/dist:/out bex-builder # # Or build fully static (musl): # docker build --target musl -t bex-builder-musl . # docker run --rm -v $(pwd)/dist:/out bex-builder-musl # =========================================================================== # Stage 1: GLIBC build (Debian Bullseye = GLIBC 2.31) # =========================================================================== FROM rust:1.79-bullseye AS glibc-build RUN apt-get update -qq && apt-get install -y -qq \ pkg-config libssl-dev cmake g++ \ && rm -rf /var/lib/apt/lists/* # Install wasm tools RUN cargo install wasm-tools-cli --locked # Add WASM target RUN rustup target add wasm32-wasip1 WORKDIR /src COPY . . # Build engine (host target) RUN cargo build --release 2>&1 | tail -5 # Build plugins (WASM target) RUN cargo build --target wasm32-wasip1 --release \ -p bex-gogoanime -p bex-kaianime -p bex-hianime \ -p bex-imdb -p bex-kisskh -p bex-yts -p bex-yflix 2>&1 | tail -5 # Convert to components RUN bash build-plugins.sh || true # Copy outputs RUN mkdir -p /out && \ cp target/release/bex /out/ 2>/dev/null || true && \ cp target/release/libbex_runtime.so /out/ 2>/dev/null || true && \ cp target/release/libbex_runtime.a /out/ 2>/dev/null || true && \ cp dist/*.bex /out/ 2>/dev/null || true CMD ["cp", "-r", "/out/.", "/dist/"] # =========================================================================== # Stage 2: Musl build (fully static, no GLIBC dependency) # =========================================================================== FROM rust:1.79-alpine AS musl RUN apk add --no-cache musl-dev openssl-dev pkgconf cmake g++ make RUN rustup target add x86_64-unknown-linux-musl RUN rustup target add wasm32-wasip1 WORKDIR /src COPY . . RUN RUSTFLAGS="-C target-feature=+crt-static" \ cargo build --release --target x86_64-unknown-linux-musl 2>&1 | tail -5 RUN mkdir -p /out && \ cp target/x86_64-unknown-linux-musl/release/bex /out/ 2>/dev/null || true && \ cp target/x86_64-unknown-linux-musl/release/libbex_runtime.a /out/ 2>/dev/null || true CMD ["cp", "-r", "/out/.", "/dist/"] # =========================================================================== # Final: minimal output image # =========================================================================== FROM debian:bullseye-slim AS final COPY --from=glibc-build /out /dist ENTRYPOINT ["cp", "-r", "/dist/.", "/out/"]