-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (21 loc) · 780 Bytes
/
Copy pathDockerfile
File metadata and controls
30 lines (21 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# syntax=docker/dockerfile:1
FROM python:3.11-slim
WORKDIR /app
# Set a build argument (default to CPU mode to save space)
ARG USE_GPU=0
COPY requirements.txt .
# Dynamically install PyTorch based on the USE_GPU flag
RUN --mount=type=cache,target=/root/.cache/pip \
if [ "$USE_GPU" = "1" ] ; then \
echo "Building for GPU..." && \
pip install -r requirements.txt ; \
else \
echo "Building for CPU..." && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu -r requirements.txt ; \
fi
# Download NLTK data separately so it gets cached
RUN python -m nltk.downloader punkt punkt_tab wordnet omw-1.4
# Copy application code
COPY . .
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]