Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +27 -18
Dockerfile
CHANGED
@@ -1,26 +1,35 @@
|
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
-
#
|
4 |
-
|
|
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
|
10 |
-
# Set environment variables
|
11 |
-
ENV NLTK_DATA=/
|
12 |
-
ENV HF_HOME=/
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
-
python -m spacy download en_core_web_sm && \
|
20 |
-
python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
|
|
|
1 |
+
# Use the official Python image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Set environment variables to prevent Python from writing .pyc files and buffering stdout
|
5 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
6 |
+
ENV PYTHONUNBUFFERED=1
|
7 |
|
8 |
+
# Create writable directories for nltk_data and huggingface_cache
|
9 |
+
RUN mkdir -p /app/nltk_data && \
|
10 |
+
mkdir -p /app/huggingface_cache && \
|
11 |
+
chmod -R 777 /app/nltk_data && \
|
12 |
+
chmod -R 777 /app/huggingface_cache
|
13 |
|
14 |
+
# Set environment variables for NLTK and Hugging Face cache directories
|
15 |
+
ENV NLTK_DATA=/app/nltk_data
|
16 |
+
ENV HF_HOME=/app/huggingface_cache
|
17 |
|
18 |
+
# Set working directory
|
19 |
+
WORKDIR /app
|
20 |
|
21 |
+
# Copy requirements.txt into the container
|
22 |
+
COPY requirements.txt /app/
|
|
|
|
|
23 |
|
24 |
+
# Install Python dependencies
|
25 |
+
RUN pip install --upgrade pip
|
26 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
27 |
+
|
28 |
+
# Copy the FastAPI app code into the container
|
29 |
+
COPY . /app/
|
30 |
+
|
31 |
+
# Expose the port for the FastAPI app
|
32 |
+
EXPOSE 7860
|
33 |
|
34 |
+
# Run FastAPI app using uvicorn
|
35 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|