File size: 1,384 Bytes
3656ccf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Rust backend for the ChessTransformer web app (replaces backend/Dockerfile).
# Build from the repo root:  docker build -f rust/ct-bot/Dockerfile .

FROM rust:1.92-slim-trixie AS builder

# ort's build script downloads the prebuilt ONNX Runtime over TLS (via ureq +
# native-tls, hence libssl-dev/pkg-config at build time).
# g++ provides libstdc++, which the statically-linked ONNX Runtime needs at link time.
RUN apt-get update && apt-get install -y --no-install-recommends \
    pkg-config ca-certificates libssl-dev g++ && rm -rf /var/lib/apt/lists/*

WORKDIR /build
COPY rust/ ./rust/
RUN cargo build --release --manifest-path rust/Cargo.toml -p ct-bot

FROM debian:trixie-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
    curl ca-certificates && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY --from=builder /build/rust/target/release/ct-bot /usr/local/bin/ct-bot
# ONNX Runtime (CPU) is statically linked; only the model is needed at runtime.
# Base int8 model — the single model used across all deliveries (default, serve,
# lichess): ~1.75x faster on the CPU EP, and the base net scales with search far
# better than EMA (generate with: export_onnx.py <dir> --quantize).
COPY data/models/pos2move_v2.1/model.int8.onnx ./model.int8.onnx

EXPOSE 5001
ENV RUST_LOG=info

CMD ["ct-bot", "serve", "--model", "/app/model.int8.onnx", "--port", "5001"]