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"]