File size: 1,039 Bytes
b32fd79
 
9d1f0c7
 
b32fd79
60db5ba
 
 
 
 
b32fd79
03a54f9
 
 
b32fd79
03a54f9
 
 
 
 
b32fd79
03a54f9
b32fd79
03a54f9
 
 
 
 
 
 
b32fd79
 
 
60db5ba
 
03a54f9
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
FROM python:3.10-slim

ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=1

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

# Set up a new user named "user" with user ID 1000 to match Hugging Face's runtime user
RUN useradd -m -u 1000 user
USER user

# Set env variables pointing to the user's home directory
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    HF_HOME=/home/user/.cache/huggingface \
    TORCH_HOME=/home/user/.cache/torch

WORKDIR $HOME/app

COPY --chown=user requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt

COPY --chown=user . .

# Run the downloader as user 'user' so weights are baked into the accessible home directory cache
RUN cd js && python download_model.py

EXPOSE 7860

# Launch uvicorn with --app-dir pointing at js/ so it finds app.py as
# a top-level module (avoids the js.app package resolution overhead)
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--app-dir", "js"]