Spaces:
Sleeping
Sleeping
GitHub Actions commited on
Commit ·
e65d77f
1
Parent(s): 1d37dfb
Deploy chatbot from GitHub Actions
Browse files- Dockerfile +2 -22
- tool.py +1 -2
Dockerfile
CHANGED
|
@@ -1,33 +1,13 @@
|
|
| 1 |
# Use Python 3.10 slim base image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
-
|
| 4 |
-
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
-
|
| 7 |
-
# Create a writable cache directory
|
| 8 |
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache
|
| 9 |
-
|
| 10 |
-
# Set environment variables for Hugging Face cache
|
| 11 |
ENV HF_HOME=/app/.cache
|
| 12 |
-
ENV TRANSFORMERS_CACHE=/app/.cache
|
| 13 |
-
|
| 14 |
-
# Copy requirements.txt
|
| 15 |
COPY requirements.txt .
|
| 16 |
-
|
| 17 |
-
# Install dependencies
|
| 18 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 19 |
-
|
| 20 |
-
# Install gunicorn
|
| 21 |
RUN pip install --no-cache-dir gunicorn
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"
|
| 25 |
-
|
| 26 |
-
# Copy application files
|
| 27 |
COPY GeminiAgent.py main.py routes.py serialization.py tool.py .
|
| 28 |
-
|
| 29 |
-
# Expose port 7860 (standard for Hugging Face Spaces)
|
| 30 |
EXPOSE 7860
|
| 31 |
-
|
| 32 |
-
# Run the application
|
| 33 |
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:7860"]
|
|
|
|
| 1 |
# Use Python 3.10 slim base image
|
| 2 |
FROM python:3.10-slim
|
|
|
|
|
|
|
| 3 |
WORKDIR /app
|
|
|
|
|
|
|
| 4 |
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache
|
|
|
|
|
|
|
| 5 |
ENV HF_HOME=/app/.cache
|
|
|
|
|
|
|
|
|
|
| 6 |
COPY requirements.txt .
|
|
|
|
|
|
|
| 7 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
| 8 |
RUN pip install --no-cache-dir gunicorn
|
| 9 |
+
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')" \
|
| 10 |
+
&& chmod -R 777 /app/.cache
|
|
|
|
|
|
|
|
|
|
| 11 |
COPY GeminiAgent.py main.py routes.py serialization.py tool.py .
|
|
|
|
|
|
|
| 12 |
EXPOSE 7860
|
|
|
|
|
|
|
| 13 |
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:7860"]
|
tool.py
CHANGED
|
@@ -8,8 +8,7 @@ from typing import List
|
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
import os
|
| 11 |
-
os.environ["HF_HOME"] = "/app/.cache"
|
| 12 |
-
os.environ["TRANSFORMERS_CACHE"] = "/app/.cache"
|
| 13 |
|
| 14 |
# Initialize embeddings
|
| 15 |
embedmodel = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
|
|
|
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
import os
|
| 11 |
+
os.environ["HF_HOME"] = "/app/.cache"
|
|
|
|
| 12 |
|
| 13 |
# Initialize embeddings
|
| 14 |
embedmodel = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
|