Commit
·
4ee91a0
1
Parent(s):
6fb7326
deploy
Browse files- Dockerfile +14 -11
Dockerfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# Use an official Python image
|
2 |
-
FROM python:3.9
|
3 |
|
4 |
# Set environment variables for cache location
|
5 |
ENV HF_HOME="/app/cache"
|
@@ -8,23 +8,26 @@ ENV TRANSFORMERS_CACHE="/app/cache"
|
|
8 |
# Create the cache directory and set permissions
|
9 |
RUN mkdir -p /app/cache && chmod -R 777 /app/cache
|
10 |
|
11 |
-
# Install required Python packages
|
12 |
-
RUN pip install --no-cache-dir uvicorn fastapi sentence-transformers
|
13 |
-
|
14 |
-
# Pre-download the model and set proper permissions
|
15 |
-
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/clip-ViT-B-32-multilingual-v1')" && chmod -R 777 /app/cache
|
16 |
-
|
17 |
# Set working directory
|
18 |
WORKDIR /app
|
19 |
|
20 |
-
# Copy
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
COPY . /app
|
22 |
|
23 |
-
# Ensure
|
24 |
RUN chmod -R 777 /app
|
25 |
|
26 |
-
#
|
|
|
|
|
|
|
27 |
EXPOSE 7860
|
28 |
|
29 |
-
# Start
|
30 |
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
# Use an official Python image
|
2 |
+
FROM python:3.9-slim
|
3 |
|
4 |
# Set environment variables for cache location
|
5 |
ENV HF_HOME="/app/cache"
|
|
|
8 |
# Create the cache directory and set permissions
|
9 |
RUN mkdir -p /app/cache && chmod -R 777 /app/cache
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Set working directory
|
12 |
WORKDIR /app
|
13 |
|
14 |
+
# Copy the requirements file first (to leverage Docker's layer caching)
|
15 |
+
COPY requirements.txt /app/
|
16 |
+
|
17 |
+
# Install dependencies from requirements.txt
|
18 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
+
|
20 |
+
# Copy the rest of the application code
|
21 |
COPY . /app
|
22 |
|
23 |
+
# Ensure all files are accessible
|
24 |
RUN chmod -R 777 /app
|
25 |
|
26 |
+
# Pre-download the model (to avoid runtime downloading issues)
|
27 |
+
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/clip-ViT-B-32-multilingual-v1')" && chmod -R 777 /app/cache
|
28 |
+
|
29 |
+
# Expose FastAPI port
|
30 |
EXPOSE 7860
|
31 |
|
32 |
+
# Start FastAPI application
|
33 |
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|