Spaces:
Runtime error
Runtime error
[Vignesh Nachu]
commited on
Commit
·
e949425
1
Parent(s):
2d02bb1
ha
Browse files- Dockerfile +17 -11
- app.py +1 -4
Dockerfile
CHANGED
@@ -1,25 +1,31 @@
|
|
1 |
-
# Use
|
2 |
-
FROM python:3.
|
3 |
|
4 |
-
#
|
5 |
-
ENV PYTHONDONTWRITEBYTECODE
|
6 |
-
ENV PYTHONUNBUFFERED
|
7 |
|
8 |
-
#
|
9 |
WORKDIR /app
|
10 |
|
|
|
11 |
RUN apt-get update && apt-get install -y \
|
12 |
build-essential \
|
|
|
13 |
&& rm -rf /var/lib/apt/lists/*
|
14 |
|
15 |
-
|
16 |
COPY requirements.txt .
|
17 |
-
RUN pip install --
|
18 |
-
|
19 |
|
|
|
20 |
COPY . .
|
21 |
|
|
|
|
|
22 |
|
23 |
-
|
|
|
24 |
|
25 |
-
|
|
|
|
1 |
+
# Use Python base image
|
2 |
+
FROM python:3.11-slim
|
3 |
|
4 |
+
# Set environment variables
|
5 |
+
ENV PYTHONDONTWRITEBYTECODE 1
|
6 |
+
ENV PYTHONUNBUFFERED 1
|
7 |
|
8 |
+
# Create working directory
|
9 |
WORKDIR /app
|
10 |
|
11 |
+
# Install system dependencies
|
12 |
RUN apt-get update && apt-get install -y \
|
13 |
build-essential \
|
14 |
+
git \
|
15 |
&& rm -rf /var/lib/apt/lists/*
|
16 |
|
17 |
+
# Copy requirements and install them
|
18 |
COPY requirements.txt .
|
19 |
+
RUN pip install --upgrade pip && pip install -r requirements.txt
|
|
|
20 |
|
21 |
+
# Copy app code
|
22 |
COPY . .
|
23 |
|
24 |
+
# Download model at build time
|
25 |
+
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
|
26 |
|
27 |
+
# Expose port
|
28 |
+
EXPOSE 8080
|
29 |
|
30 |
+
# Run app
|
31 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]
|
app.py
CHANGED
@@ -9,9 +9,6 @@ from sentence_transformers import SentenceTransformer
|
|
9 |
import weaviate
|
10 |
from weaviate.classes.init import Auth
|
11 |
|
12 |
-
os.environ["HF_HOME"] = "/tmp/.cache/huggingface"
|
13 |
-
os.environ["TRANSFORMERS_CACHE"] = "/tmp/.cache/transformers"
|
14 |
-
os.environ["SENTENCE_TRANSFORMERS_CACHE"] = "/tmp/.cache/sentence_transformers"
|
15 |
|
16 |
WEAVIATE_URL = os.getenv("WEAVIATE_URL", "https://hrdhwtqlrkqmc8sfizwvpq.c0.asia-southeast1.gcp.weaviate.cloud")
|
17 |
WEAVIATE_API_KEY = os.getenv("WEAVIATE_API_KEY", "pMDX7ysJPkSTUMdV3gEwxhGmyB7wB301fLaJ")
|
@@ -28,7 +25,7 @@ app.add_middleware(
|
|
28 |
|
29 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
30 |
|
31 |
-
model = SentenceTransformer("
|
32 |
|
33 |
client = weaviate.connect_to_weaviate_cloud(
|
34 |
cluster_url=WEAVIATE_URL,
|
|
|
9 |
import weaviate
|
10 |
from weaviate.classes.init import Auth
|
11 |
|
|
|
|
|
|
|
12 |
|
13 |
WEAVIATE_URL = os.getenv("WEAVIATE_URL", "https://hrdhwtqlrkqmc8sfizwvpq.c0.asia-southeast1.gcp.weaviate.cloud")
|
14 |
WEAVIATE_API_KEY = os.getenv("WEAVIATE_API_KEY", "pMDX7ysJPkSTUMdV3gEwxhGmyB7wB301fLaJ")
|
|
|
25 |
|
26 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
27 |
|
28 |
+
model = SentenceTransformer("all-MiniLM-L6-v2")
|
29 |
|
30 |
client = weaviate.connect_to_weaviate_cloud(
|
31 |
cluster_url=WEAVIATE_URL,
|