diff --git a/Dockerfile b/Dockerfile index 6dfd65ae..b82850a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,9 @@ ARG GO_VERSION=1.20 -ARG DEBIAN_VERSION=11 ARG BUILD_TYPE= - -FROM golang:$GO_VERSION as builder +FROM golang:$GO_VERSION WORKDIR /build RUN apt-get update && apt-get install -y cmake COPY . . -RUN make build - -FROM debian:$DEBIAN_VERSION -COPY --from=builder /build/local-ai /usr/bin/local-ai +RUN make prepare-sources EXPOSE 8080 -ENTRYPOINT [ "/usr/bin/local-ai" ] +ENTRYPOINT [ "/build/entrypoint.sh" ] diff --git a/Makefile b/Makefile index 6479f818..97e9d8af 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ go-gpt2/libgpt2.a: go-gpt2 go-llama: git clone -b $(GOLLAMA_VERSION) --recurse-submodules https://github.com/go-skynet/go-llama.cpp go-llama -go-llama/libbinding.a: go-llama +go-llama/libbinding.a: go-llama $(MAKE) -C go-llama $(GENERIC_PREFIX)libbinding.a replace: @@ -87,7 +87,16 @@ replace: $(GOCMD) mod edit -replace github.com/go-skynet/go-gpt4all-j.cpp=$(shell pwd)/go-gpt4all-j $(GOCMD) mod edit -replace github.com/go-skynet/go-gpt2.cpp=$(shell pwd)/go-gpt2 -prepare: go-llama/libbinding.a go-gpt4all-j/libgptj.a go-gpt2/libgpt2.a replace +prepare-sources: go-llama go-gpt2 go-gpt4all-j + $(GOCMD) mod download + +rebuild: + $(MAKE) -C go-llama clean + $(MAKE) -C go-gpt4all-j clean + $(MAKE) -C go-gpt2 clean + $(MAKE) build + +prepare: prepare-sources go-llama/libbinding.a go-gpt4all-j/libgptj.a go-gpt2/libgpt2.a replace clean: ## Remove build related file rm -fr ./go-llama diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..aab14205 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd /build + +make build + +./local-ai "$@" \ No newline at end of file