FROM alpine:latest AS assets

RUN apk add git git-lfs
WORKDIR /app
RUN git clone https://huggingface.co/Supertone/supertonic-3 assets && rm -r assets/.git

FROM rust:trixie AS builder

RUN apt-get update && apt-get install -y --no-install-recommends \
    pkg-config libssl-dev
WORKDIR /app
ADD . .
RUN cargo build --profile=release

FROM debian:trixie-slim AS runtime

RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg
WORKDIR /app
COPY --from=assets /app/assets /app/assets
COPY --from=builder /app/target/release/yaejuyang-supertonic /app/
ENV SUPERTONIC_MODEL_DIR="/app/assets"
