-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (57 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
73 lines (57 loc) · 1.9 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Multi-stage Rust build for whisper-rust-api
#
# GPU Note: This container builds CPU-only by default. Apple Metal GPU is NOT
# available inside Linux containers (Docker/Podman run a Linux VM on macOS,
# which has no access to the Metal framework). For GPU-accelerated transcription:
# - macOS: Run natively with `./run/dev.sh start` (Metal is auto-enabled)
# - Linux + NVIDIA: Build with `docker build --build-arg GPU_FEATURES=cuda .`
# Stage 1: Builder
FROM rust:latest as builder
# GPU acceleration: set to "cuda" for NVIDIA GPU support, or leave empty for CPU-only.
# "metal" is NOT supported in containers (see note above).
ARG GPU_FEATURES=""
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
pkg-config \
libssl-dev \
clang \
libclang-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy Cargo files
COPY Cargo.toml Cargo.lock* ./
# Copy source code
COPY src ./src
# Build application (pass --features cuda via GPU_FEATURES for NVIDIA GPU support)
RUN if [ -n "$GPU_FEATURES" ]; then \
cargo build --release --features "$GPU_FEATURES"; \
else \
cargo build --release; \
fi
# Stage 2: Runtime
FROM debian:testing
WORKDIR /app
# Install runtime dependencies (including ffmpeg for audio format conversion)
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
ca-certificates \
curl \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Copy binary from builder
COPY --from=builder /app/target/release/whisper-rust-api /app/
# Create models directory
RUN mkdir -p /app/models
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Expose port
EXPOSE 8000
# Environment
ENV RUST_LOG=info
ENV WHISPER_HOST=0.0.0.0
ENV WHISPER_PORT=8000
# Run application
ENTRYPOINT ["/app/whisper-rust-api"]
CMD []