-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
59 lines (43 loc) · 1.41 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
# Name the single Python image we're using everywhere.
ARG python=python:3.10-slim
# Build stage:
FROM ${python} AS build
# Install a full C toolchain and C build-time dependencies for
# everything we're going to need.
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends --assume-yes \
build-essential \
libpq-dev
# Create the virtual environment.
RUN python3 -m venv /venv
ENV PATH=/venv/bin:$PATH
# Install the Python library dependencies, including those with
# C extensions. They'll get installed into the virtual environment.
WORKDIR /app
COPY requirements.txt create_vector_index.py ./
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Accept build argument
ARG OPENAI_API_KEY
# Create the vector database
ENV OPENAI_API_KEY=$OPENAI_API_KEY
RUN python create_vector_index.py
# Final stage:
FROM ${python}
# Install the runtime-only C library dependencies we need.
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends --assume-yes \
libpq5
WORKDIR /app
# Copy the virtual environment from the first stage.
COPY --from=build /venv /venv
ENV PATH=/venv/bin:$PATH
# Copy the vector index
COPY --from=build /app/vector-database/ .
# Copy the public key in
COPY public_key.pem ./
# Copy the application in.
COPY app.py utils.py ./
EXPOSE 5000
CMD ["fastapi", "run", "app.py", "--port", "5000"]