Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +11 -6
Dockerfile
CHANGED
@@ -31,18 +31,23 @@ RUN mkdir -p $HF_HOME && \
|
|
31 |
# Copy application files
|
32 |
COPY main.py .
|
33 |
|
34 |
-
# Set up Hugging Face token as a build argument
|
35 |
ARG HF_TOKEN
|
36 |
ENV HF_TOKEN=${HF_TOKEN}
|
37 |
|
38 |
-
#
|
39 |
USER appuser
|
40 |
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
|
44 |
-
RUN /app/venv/bin/python -c "from
|
45 |
-
|
|
|
|
|
46 |
|
47 |
# Expose FastAPI port
|
48 |
EXPOSE 7860
|
|
|
31 |
# Copy application files
|
32 |
COPY main.py .
|
33 |
|
34 |
+
# Set up Hugging Face token as a build argument
|
35 |
ARG HF_TOKEN
|
36 |
ENV HF_TOKEN=${HF_TOKEN}
|
37 |
|
38 |
+
# Switch to the non-root user
|
39 |
USER appuser
|
40 |
|
41 |
+
# Authenticate with Hugging Face and download models
|
42 |
+
RUN /app/venv/bin/python -c "from huggingface_hub import login; \
|
43 |
+
login(token='$HF_TOKEN'); \
|
44 |
+
from transformers import pipeline; \
|
45 |
+
pipeline('sentiment-analysis', model='Ehrii/sentiment')" || echo 'Failed to download multilingual model'
|
46 |
|
47 |
+
RUN /app/venv/bin/python -c "from huggingface_hub import login; \
|
48 |
+
login(token='$HF_TOKEN'); \
|
49 |
+
from transformers import pipeline; \
|
50 |
+
pipeline('sentiment-analysis', model='siebert/sentiment-roberta-large-english')" || echo 'Failed to download English model'
|
51 |
|
52 |
# Expose FastAPI port
|
53 |
EXPOSE 7860
|