-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (35 loc) · 1.45 KB
/
Dockerfile
File metadata and controls
48 lines (35 loc) · 1.45 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Use the official Python 3.12 image as the base
FROM python:3.12-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
RUN apt-get update && apt-get install -y curl gcc
# Download and install Miniconda based on architecture
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
curl -sSLo /tmp/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; \
elif [ "$ARCH" = "aarch64" ]; then \
curl -sSLo /tmp/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi && \
bash /tmp/miniconda.sh -b -p /opt/conda && \
rm /tmp/miniconda.sh && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Add conda to PATH
ENV PATH="/opt/conda/bin:$PATH"
# Set the working directory in the container
WORKDIR /app
# Copy the requirements file into the container
COPY requirements.txt /app/
# Install the pip dependencies from requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Install conda dependencies
RUN conda install -c conda-forge faiss-cpu spacy nltk
# Download the spaCy model (en_core_web_sm)
RUN python -m spacy download en_core_web_sm
RUN python -c "import nltk; nltk.download('stopwords')"
# Copy the FastAPI application code
COPY . /app/
# Command to run the FastAPI app with Uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]