-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·65 lines (52 loc) · 1.39 KB
/
Dockerfile
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Base image for building and installing dependencies
FROM python:3.9-slim AS builder
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
libeigen3-dev \
gcc \
libpq-dev \
libsnappy-dev \
zlib1g-dev \
libbz2-dev \
libgflags-dev \
liblz4-dev \
libzstd-dev \
wget \
git
# Install pybind11
RUN python -m pip install pybind11
# Install Python dependencies
COPY requirements.txt .
RUN python -m pip install --upgrade pip && \
python -m pip install -r requirements.txt
# Clone and build hnswlib from source
RUN git clone https://github.com/nmslib/hnswlib.git && \
cd hnswlib && \
mkdir build && \
cd build && \
cmake .. && \
make -j $(nproc) && \
make install
# Final image for running the application
FROM python:3.9-slim
WORKDIR /app
# Copy the built hnswlib from the builder stage
COPY --from=builder /usr/local/lib/python3.9/site-packages/ /usr/local/lib/python3.9/site-packages/
# Copy the application files
COPY . .
# Install runtime Python dependencies
RUN apt-get update && apt-get install -y \
libpq-dev \
libsnappy-dev \
zlib1g-dev \
libbz2-dev \
libgflags-dev \
liblz4-dev \
libzstd-dev \
&& rm -rf /var/lib/apt/lists/*
# Install application dependencies
EXPOSE 80
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]