From 16773e2a350484f55ce6548475011c7d20140f9e Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sat, 29 Apr 2023 20:38:37 +0200 Subject: [PATCH] feat: make images to build sources on start (#124) Signed-off-by: mudler --- Dockerfile | 11 +++-------- Makefile | 13 +++++++++++-- entrypoint.sh | 7 +++++++ 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 6dfd65a..b82850a 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 6479f81..97e9d8a 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 0000000..aab1420 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd /build + +make build + +./local-ai "$@" \ No newline at end of file