Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +7 -12
Dockerfile
CHANGED
|
@@ -31,26 +31,21 @@ 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 |
-
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
|
| 48 |
-
|
| 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
|
| 54 |
|
| 55 |
# Run FastAPI server using the virtual environment
|
| 56 |
-
CMD ["/app/venv/bin/uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 31 |
# Copy application files
|
| 32 |
COPY main.py .
|
| 33 |
|
| 34 |
+
# Set up Hugging Face token as a build argument (secured via environment variables)
|
| 35 |
ARG HF_TOKEN
|
| 36 |
ENV HF_TOKEN=${HF_TOKEN}
|
| 37 |
|
| 38 |
+
# Pre-download models as the new user
|
| 39 |
USER appuser
|
| 40 |
|
| 41 |
+
RUN /app/venv/bin/python -c "from transformers import pipeline; \
|
| 42 |
+
pipeline('sentiment-analysis', model='Ehrii/sentiment', use_auth_token='$HF_TOKEN')" || echo 'Failed to download multilingual model'
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
RUN /app/venv/bin/python -c "from transformers import pipeline; \
|
| 45 |
+
pipeline('sentiment-analysis', model='siebert/sentiment-roberta-large-english', use_auth_token='$HF_TOKEN')" || echo 'Failed to download English model'
|
|
|
|
|
|
|
| 46 |
|
| 47 |
# Expose FastAPI port
|
| 48 |
EXPOSE 7860
|
| 49 |
|
| 50 |
# Run FastAPI server using the virtual environment
|
| 51 |
+
CMD ["/app/venv/bin/uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|