From 2d738f8530d6fdfb2f5d2a9d4fc1956dd012488a Mon Sep 17 00:00:00 2001 From: samm81 Date: Tue, 13 Jun 2023 21:51:30 -0500 Subject: [PATCH] Dockerfile: cache results of `prepare` even when source changes since dependency hashes are kept in the `Makefile`, changing them will make `docker` start from the `COPY Makefile .` line, which will then correctly refetch sources however, if only go source files are touched, `docker` won't throwaway all the fetching and compiling it did previously --- Dockerfile | 7 +++++-- Makefile | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2b84b694..98e638e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,6 +41,10 @@ ENV NVIDIA_VISIBLE_DEVICES=all WORKDIR /build +COPY Makefile . +RUN make get-sources +COPY go.mod . +RUN make prepare COPY . . RUN make build @@ -58,9 +62,8 @@ RUN if [ "${FFMPEG}" = "true" ]; then \ WORKDIR /build -COPY . . -RUN make prepare-sources COPY --from=builder /build/local-ai ./ +COPY entrypoint.sh . # Define the health check command HEALTHCHECK --interval=1m --timeout=10m --retries=10 \ diff --git a/Makefile b/Makefile index 10d8ccdd..ee03c583 100644 --- a/Makefile +++ b/Makefile @@ -171,6 +171,9 @@ go-llama: go-llama/libbinding.a: go-llama $(MAKE) -C go-llama BUILD_TYPE=$(BUILD_TYPE) libbinding.a +get-sources: go-llama go-ggml-transformers gpt4all go-rwkv whisper.cpp go-bert bloomz go-stable-diffusion + touch $@ + replace: $(GOCMD) mod edit -replace github.com/go-skynet/go-llama.cpp=$(shell pwd)/go-llama $(GOCMD) mod edit -replace github.com/nomic-ai/gpt4all/gpt4all-bindings/golang=$(shell pwd)/gpt4all/gpt4all-bindings/golang @@ -181,7 +184,7 @@ replace: $(GOCMD) mod edit -replace github.com/go-skynet/bloomz.cpp=$(shell pwd)/bloomz $(GOCMD) mod edit -replace github.com/mudler/go-stable-diffusion=$(shell pwd)/go-stable-diffusion -prepare-sources: go-llama go-ggml-transformers gpt4all go-rwkv whisper.cpp go-bert bloomz go-stable-diffusion replace +prepare-sources: get-sources replace $(GOCMD) mod download ## GENERIC @@ -197,6 +200,7 @@ rebuild: ## Rebuilds the project $(MAKE) build prepare: prepare-sources backend-assets/gpt4all $(OPTIONAL_TARGETS) go-llama/libbinding.a go-bert/libgobert.a go-ggml-transformers/libtransformers.a go-rwkv/librwkv.a whisper.cpp/libwhisper.a bloomz/libbloomz.a ## Prepares for building + touch $@ clean: ## Remove build related file rm -fr ./go-llama