File size: 1,739 Bytes
c3156f6
 
 
 
 
 
d696627
c3156f6
 
 
 
 
 
515204e
c3156f6
 
 
 
2c83848
 
 
 
 
 
 
 
c3156f6
d27be80
c2cb7b8
c3156f6
c2cb7b8
 
 
 
c3156f6
c2cb7b8
c3156f6
 
 
c2cb7b8
 
 
 
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
FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV UV_NO_DEV=1
ENV UV_NO_CACHE=1
ENV GRADIO_ANALYTICS_ENABLED="False"

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

RUN apt-get update && apt-get install -y \
    git \
    git-lfs \
    ffmpeg \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && git lfs install

# HF Spaces runs the container as a non-root user (UID 1000) at runtime. Create
# that user and build everything under it so it owns the .venv and can execute
# /app/esp-research/.venv/bin/python3.
RUN useradd -m -u 1000 user
RUN mkdir -p /app && chown -R user:user /app
USER user
ENV HOME=/home/user

RUN --mount=type=secret,id=GH_TOKEN,mode=0444,required=true \
    git -c "http.https://github.com/.extraheader=Authorization: Basic $(printf 'x-access-token:%s' "$(cat /run/secrets/GH_TOKEN)" | base64 | tr -d '\n')" \
        clone --single-branch --depth 1 --branch fix-hf-app-cuda-torch https://github.com/earthspecies/esp-research.git /app/esp-research

# alp-data is now published on PyPI and is in esp-research's pyproject.toml,
# so uv sync resolves it directly, no clone needed.
# Sync this app's package (and its `gpu` group, which pins torch/torchaudio to
# the cu126 index) so the venv built here is exactly what the app runs with.
WORKDIR /app/esp-research
RUN uv sync --frozen --package naturelm-audio-hf-app --group gpu

WORKDIR /app/esp-research/projects/NatureLM-audio-hf-app
EXPOSE 7860
# --no-sync: never re-resolve at container start. `uv run` would otherwise sync
# the app package without its `gpu` group and replace the cu126 torch stack with
# the CUDA 13 wheel from PyPI.
CMD ["uv", "run", "--no-sync", "app.py"]