krystv commited on
Commit
2791b61
·
verified ·
1 Parent(s): 2753d8f

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +79 -0
Dockerfile ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BEX Engine — Portable Build Container
2
+ # Produces binaries compatible with GLIBC 2.31+ (Ubuntu 20.04+, Debian 11+)
3
+ #
4
+ # Usage:
5
+ # docker build -t bex-builder .
6
+ # docker run --rm -v $(pwd)/dist:/out bex-builder
7
+ #
8
+ # Or build fully static (musl):
9
+ # docker build --target musl -t bex-builder-musl .
10
+ # docker run --rm -v $(pwd)/dist:/out bex-builder-musl
11
+
12
+ # ===========================================================================
13
+ # Stage 1: GLIBC build (Debian Bullseye = GLIBC 2.31)
14
+ # ===========================================================================
15
+ FROM rust:1.79-bullseye AS glibc-build
16
+
17
+ RUN apt-get update -qq && apt-get install -y -qq \
18
+ pkg-config libssl-dev cmake g++ \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Install wasm tools
22
+ RUN cargo install wasm-tools-cli --locked
23
+
24
+ # Add WASM target
25
+ RUN rustup target add wasm32-wasip1
26
+
27
+ WORKDIR /src
28
+ COPY . .
29
+
30
+ # Build engine (host target)
31
+ RUN cargo build --release 2>&1 | tail -5
32
+
33
+ # Build plugins (WASM target)
34
+ RUN cargo build --target wasm32-wasip1 --release \
35
+ -p bex-gogoanime -p bex-kaianime -p bex-hianime \
36
+ -p bex-imdb -p bex-kisskh -p bex-yts -p bex-yflix 2>&1 | tail -5
37
+
38
+ # Convert to components
39
+ RUN bash build-plugins.sh || true
40
+
41
+ # Copy outputs
42
+ RUN mkdir -p /out && \
43
+ cp target/release/bex /out/ 2>/dev/null || true && \
44
+ cp target/release/libbex_runtime.so /out/ 2>/dev/null || true && \
45
+ cp target/release/libbex_runtime.a /out/ 2>/dev/null || true && \
46
+ cp dist/*.bex /out/ 2>/dev/null || true
47
+
48
+ CMD ["cp", "-r", "/out/.", "/dist/"]
49
+
50
+ # ===========================================================================
51
+ # Stage 2: Musl build (fully static, no GLIBC dependency)
52
+ # ===========================================================================
53
+ FROM rust:1.79-alpine AS musl
54
+
55
+ RUN apk add --no-cache musl-dev openssl-dev pkgconf cmake g++ make
56
+
57
+ RUN rustup target add x86_64-unknown-linux-musl
58
+ RUN rustup target add wasm32-wasip1
59
+
60
+ WORKDIR /src
61
+ COPY . .
62
+
63
+ RUN RUSTFLAGS="-C target-feature=+crt-static" \
64
+ cargo build --release --target x86_64-unknown-linux-musl 2>&1 | tail -5
65
+
66
+ RUN mkdir -p /out && \
67
+ cp target/x86_64-unknown-linux-musl/release/bex /out/ 2>/dev/null || true && \
68
+ cp target/x86_64-unknown-linux-musl/release/libbex_runtime.a /out/ 2>/dev/null || true
69
+
70
+ CMD ["cp", "-r", "/out/.", "/dist/"]
71
+
72
+ # ===========================================================================
73
+ # Final: minimal output image
74
+ # ===========================================================================
75
+ FROM debian:bullseye-slim AS final
76
+
77
+ COPY --from=glibc-build /out /dist
78
+
79
+ ENTRYPOINT ["cp", "-r", "/dist/.", "/out/"]