forked from jrusz/privategpt-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile
67 lines (49 loc) · 1.74 KB
/
Containerfile
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
66
67
FROM nvidia/cuda:12.3.1-devel-ubi9 as builder
# install deps
RUN dnf install -y pip git zlib-devel bzip2-devel openssl-devel xz-devel sqlite-devel libffi-devel ncurses-devel
# install pyenv
RUN curl https://pyenv.run | bash
# set env vars for pyenv
ENV HOME /root
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/bin:$PATH
# install python 3.11
RUN pyenv install 3.11 && \
pyenv global 3.11 && \
pyenv rehash
# install poetry
RUN pip install poetry
RUN git clone https://github.com/imartinez/privateGPT.git /app
WORKDIR /app
# create the .venv inside the project
ENV POETRY_VIRTUALENVS_IN_PROJECT true
# install deps with poetry
RUN poetry env use $(pyenv which python) && \
poetry install --with ui && \
poetry install --with local
# recompile llama-cpp with cuda support
RUN CMAKE_ARGS='-DLLAMA_CUBLAS=on' poetry run pip install --force-reinstall --no-cache-dir llama-cpp-python
# Cleanup
RUN rm -rf /root/.pyenv/cache && \
poetry cache clear PyPI --all && \
poetry cache clear _default_cache --all
# Define the base image for the production stage
FROM registry.access.redhat.com/ubi9/ubi:latest as production
# Copy Python 3.11 installation and venv from the builder stage
COPY --from=builder /root/.pyenv /root/.pyenv
COPY --from=builder /app/.venv /venv
# Set environment variables to use Python 3.11 installed via pyenv
ENV HOME /root
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
ENV POETRY_VIRTUALENVS_IN_PROJECT true
# Install make and poetry
RUN dnf -y install make && \
pip install poetry
# Run entrypoint script
COPY entrypoint.sh entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
# Set the working directory in the production image
WORKDIR /app
# run privateGPT by default
CMD ["make", "run"]