Add universal docker image

This commit is contained in:
Andrei Betlen 2023-07-07 03:38:51 -04:00
parent 57d8ec3899
commit ca11673061
3 changed files with 44 additions and 0 deletions

View file

@ -36,6 +36,12 @@ deploy.gh-docs:
test: test:
python3 -m pytest python3 -m pytest
docker:
docker build -t llama-cpp-python:latest -f docker/simple/Dockerfile .
run-server:
uvicorn --factory llama.server:app --host ${HOST} --port ${PORT}
clean: clean:
- cd vendor/llama.cpp && make clean - cd vendor/llama.cpp && make clean
- cd vendor/llama.cpp && rm libllama.so - cd vendor/llama.cpp && rm libllama.so
@ -56,4 +62,5 @@ clean:
build.sdist \ build.sdist \
deploy.pypi \ deploy.pypi \
deploy.gh-docs \ deploy.gh-docs \
docker \
clean clean

33
docker/simple/Dockerfile Normal file
View file

@ -0,0 +1,33 @@
# Define the image argument and provide a default value
ARG IMAGE=python:3-slim-bullseye
# Use the image as specified
FROM ${IMAGE}
# Re-declare the ARG after FROM
ARG IMAGE
# Update and upgrade the existing packages
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
ninja-build \
build-essential
RUN mkdir /app
WORKDIR /app
COPY . /app
RUN python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi uvicorn sse-starlette
RUN make build && make clean
# Set environment variable for the host
ENV HOST=0.0.0.0
ENV PORT=8000
# Expose a port for the server
EXPOSE 8000
# Run the server start script
CMD ["/bin/sh", "/app/docker/simple/run.sh"]

4
docker/simple/run.sh Normal file
View file

@ -0,0 +1,4 @@
#!/bin/bash
make build
uvicorn --factory llama_cpp.server.app:create_app --host $HOST --port $PORT