FROM python:3.10-slim AS runtime ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ HF_HUB_DISABLE_SYMLINKS_WARNING=1 \ HF_HUB_DISABLE_PROGRESS_BARS=1 \ OPENBLAS_NUM_THREADS=1 \ OMP_NUM_THREADS=1 \ GOTO_NUM_THREADS=1 \ QWENASR_LIBRARY_PATH=/opt/qwenasr/lib/libqwen_asr.so # Install system packages required for audio processing RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ sox \ libsox-dev \ libsndfile1 \ libopenblas-dev \ nginx \ build-essential \ curl WORKDIR /app ARG TARGETARCH ARG QWENASR_RUST_TARGET_CPU=x86-64-v2 COPY vendor/qwenasr /tmp/qwenasr # Install Rust compiler (required for sudachipy on ARM64) RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" # Build QwenASR Rust shared library for CPU Qwen3-ASR inference. The default # amd64 target stays portable across common AVX2-era servers; set # QWENASR_RUST_TARGET_CPU=native only for self-built, host-specific images. RUN if [ "$TARGETARCH" = "amd64" ]; then export RUSTFLAGS="-C target-cpu=${QWENASR_RUST_TARGET_CPU}"; fi \ && cargo build --release -p qwen-asr --features ffi --manifest-path /tmp/qwenasr/Cargo.toml \ && mkdir -p /opt/qwenasr/lib \ && cp /tmp/qwenasr/target/release/libqwen_asr.so /opt/qwenasr/lib/libqwen_asr.so # Install Python dependencies (CPU mode) COPY environments/cpu/pyproject.toml /app/environments/cpu/pyproject.toml RUN python - <<'PY' > /tmp/qwen3-asr-cpu-reqs.txt import tomllib from pathlib import Path data = tomllib.loads(Path("/app/environments/cpu/pyproject.toml").read_text()) for dep in data["project"]["dependencies"]: print(dep) print("asyncpg==0.31.0") PY RUN pip install --no-cache-dir -r /tmp/qwen3-asr-cpu-reqs.txt && \ rm -f /tmp/qwen3-asr-cpu-reqs.txt # Clean build tools and cache to reduce image size RUN apt remove -y build-essential curl && apt autoremove -y \ && rm -rf /tmp/qwenasr \ && rm -rf /root/.cargo /root/.rustup \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Copy application code COPY . . # Create runtime directories RUN mkdir -p /app/data/temp /app/data/logs /app/data/tasks \ && chmod +x start.py /app/scripts/docker/entrypoint.sh EXPOSE 8000 ENTRYPOINT ["/app/scripts/docker/entrypoint.sh"] CMD ["python", "start.py"]