gigastt 1.0.2

Local STT server powered by GigaAM v3 e2e_rnnt — on-device Russian speech recognition via ONNX Runtime
Documentation
# Multi-stage build for gigastt with CUDA support
# Build: docker build -f Dockerfile.cuda -t gigastt-cuda .
# Run:   docker run --gpus all -p 9876:9876 gigastt-cuda
#
# CUDA binary falls back to CPU if no GPU is available at runtime.

# --- Builder stage ---
FROM nvidia/cuda:12.6.3-devel-ubuntu22.04 AS builder

# `protobuf-compiler` feeds prost-build (build.rs); everything else is the
# baseline toolchain needed to compile the crate + its C deps.
RUN apt-get update && \
    apt-get install -y --no-install-recommends curl build-essential pkg-config protobuf-compiler && \
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.85.0 && \
    rm -rf /var/lib/apt/lists/*

ENV PATH="/root/.cargo/bin:${PATH}"

WORKDIR /build

# Dependency-compilation cache (see Dockerfile for rationale).
COPY Cargo.toml Cargo.lock build.rs ./
COPY proto/ proto/
RUN mkdir -p src && \
    echo 'fn main() {}' > src/main.rs && \
    touch src/lib.rs && \
    cargo build --release --features cuda && \
    rm -rf src target/release/deps/gigastt-* target/release/gigastt*

COPY src/ src/

# ort's download-binaries feature fetches CUDA-enabled ONNX Runtime.
# copy-dylibs copies libonnxruntime*.so to target/release/.
RUN cargo build --release --features cuda && \
    strip target/release/gigastt

# --- Model bake stage (runs only when GIGASTT_BAKE_MODEL=1) ---
FROM debian:bookworm-slim AS model-fetcher

ARG GIGASTT_BAKE_MODEL=0

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

COPY --from=builder /build/target/release/gigastt /usr/local/bin/gigastt

RUN mkdir -p /models && \
    if [ "$GIGASTT_BAKE_MODEL" = "1" ]; then \
        gigastt download --model-dir /models; \
    fi

# --- Runtime stage ---
FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04

ARG GIGASTT_BAKE_MODEL=0

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

# Copy binary AND ort's dynamic libraries (.so files copied by copy-dylibs)
COPY --from=builder /build/target/release/gigastt /usr/local/bin/gigastt
COPY --from=builder /build/target/release/libonnxruntime*.so* /usr/local/lib/
RUN ldconfig

RUN groupadd -r gigastt && useradd -r -g gigastt gigastt && \
    mkdir -p /home/gigastt/.gigastt/models && chown -R gigastt:gigastt /home/gigastt

# Copy baked model files (only present when GIGASTT_BAKE_MODEL=1)
COPY --from=model-fetcher --chown=gigastt:gigastt /models/. /home/gigastt/.gigastt/models/

USER gigastt

ENV RUST_LOG=gigastt=info
ENV NVIDIA_VISIBLE_DEVICES=all
ENV LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"

EXPOSE 9876

HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
    CMD curl -f http://localhost:9876/health || exit 1

ENTRYPOINT ["gigastt"]
CMD ["serve", "--port", "9876", "--host", "0.0.0.0", "--bind-all"]