feat: start script (#367)

* feat: start script

* make faster
This commit is contained in:
Matt 2023-06-23 13:20:03 +01:00 committed by GitHub
parent 3922d8ca83
commit d9b2be19d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 11 deletions

View File

@ -9,17 +9,10 @@ COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt --timeout 100 RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt --timeout 100
# Install additional dependencies #You may need to run `chmod +x ./backend/scripts/start.sh` on your host machine if you get a permission error
RUN apt-get install -y liblzma-dev cmake COPY ./scripts/start.sh /code/scripts/start.sh
RUN chmod +x /code/scripts/start.sh
# Build GPT4All from source (required for GPT4All langchain bindings)
RUN cd /tmp && git clone --recurse-submodules https://github.com/nomic-ai/gpt4all && \
cd gpt4all/gpt4all-backend/ && \
mkdir build && cd build && \
cmake .. && cmake --build . --parallel && \
cd ../../gpt4all-bindings/python && \
pip3 install -e .
COPY . /code/ COPY . /code/
CMD ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0", "--port", "5050"] ENTRYPOINT ["/code/scripts/start.sh"]

21
backend/scripts/start.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# Check if gpt4all is already installed
if ! pip show gpt4all > /dev/null; then
if [[ $PRIVATE == "True" ]]; then
apt-get install -y liblzma-dev cmake
cd /tmp && git clone --recurse-submodules https://github.com/nomic-ai/gpt4all
cd gpt4all/gpt4all-backend/
mkdir build && cd build
cmake .. && cmake --build . --parallel
cd ../../gpt4all-bindings/python
pip3 install -e .
fi
fi
# Move to the code directory
cd /code
# Start your app
uvicorn main:app --reload --host 0.0.0.0 --port 5050