File size: 1,526 Bytes
7f96697 d6861a6 accfd43 7f96697 accfd43 7f96697 accfd43 7f96697 accfd43 | 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 | # Stage 1: Build Rust binary (fully static via musl — no GLIBC dependency)
FROM rust:1.85-slim as builder
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
musl-tools \
&& rm -rf /var/lib/apt/lists/* \
&& rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml .
COPY main.rs .
COPY models.rs .
COPY utils.rs .
RUN cargo build --release --target x86_64-unknown-linux-musl
# Stage 2: Runtime with MFA
FROM condaforge/mambaforge:latest
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Etc/UTC \
MFA_ROOT_DIR=/mfa \
PATH=/env/bin:$PATH
# System deps
RUN apt-get update && apt-get install -y --no-install-recommends \
tzdata ffmpeg libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
# Conda env + MFA
RUN mkdir -p /mfa && \
mamba create -p /env -c conda-forge -y \
montreal-forced-aligner \
python=3.11 && \
/env/bin/pip install --no-cache-dir \
praatio>=6.0 \
numpy && \
conda clean -afy
# Download models
RUN /env/bin/mfa model download acoustic english_mfa && \
/env/bin/mfa model download dictionary english_mfa
# Copy Rust binary (from musl target — fully static, no GLIBC needed)
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/mfa-aligner-rust /app/
# Copy Python worker
COPY --chown=root:root worker_mfa.py /app/worker_mfa.py
# Create user
RUN useradd -ms /bin/bash -u 1000 mfauser && \
chown -R 1000:1000 /mfa /env /app
USER 1000
WORKDIR /app
EXPOSE 7860
CMD ["./mfa-aligner-rust"] |