Sadeep Sachintha commited on
Commit
094e942
·
1 Parent(s): f03d149

Fix HF Space build error by adding secret mount to pre-download step

Browse files
Files changed (1) hide show
  1. Dockerfile +2 -1
Dockerfile CHANGED
@@ -23,7 +23,8 @@ COPY --chown=user . $HOME/app
23
 
24
  # Pre-download the Hugging Face model during the build stage
25
  # This saves time and bandwidth during container startup
26
- RUN python -c "from transformers import pipeline; pipeline('sentiment-analysis', model='keshan/sinhala-sentiment-analysis')"
 
27
 
28
  # Make port 7860 available to the world outside this container
29
  EXPOSE 7860
 
23
 
24
  # Pre-download the Hugging Face model during the build stage
25
  # This saves time and bandwidth during container startup
26
+ RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
27
+ python -c "import os; from transformers import pipeline; token = open('/run/secrets/HF_TOKEN').read().strip(); pipeline('sentiment-analysis', model='keshan/sinhala-sentiment-analysis', token=token)"
28
 
29
  # Make port 7860 available to the world outside this container
30
  EXPOSE 7860