diff --git a/backend/Dockerfile.golang b/backend/Dockerfile.golang index c7dcac400..fea0804f3 100644 --- a/backend/Dockerfile.golang +++ b/backend/Dockerfile.golang @@ -248,10 +248,48 @@ RUN </dev/null 2>&1; then \ + echo "==> prebuilding engine for ${BACKEND} (cacheable layer)" && \ + make engine; \ + else \ + echo "==> ${BACKEND} has no engine target; it builds with the backend"; \ + fi + +COPY . /LocalAI + +# The engine variants built above survive this COPY (they are build outputs, not +# tracked files) and are newer than the pinned clone, so make treats them as up +# to date and goes straight to the Go binary. RUN cd /LocalAI && make protogen-go && make -C /LocalAI/backend/go/${BACKEND} build FROM scratch diff --git a/backend/go/depth-anything-cpp/Makefile b/backend/go/depth-anything-cpp/Makefile index 54f17f60f..fe9071631 100644 --- a/backend/go/depth-anything-cpp/Makefile +++ b/backend/go/depth-anything-cpp/Makefile @@ -82,6 +82,16 @@ else VARIANT_TARGETS = libdepthanythingcpp-fallback.dylib endif +## Builds the native engine variants and stops short of the Go binary. The +## variants depend only on sources/depth-anything.cpp, a clone pinned by +## DEPTHANYTHING_VERSION, so nothing in this target can observe a change +## elsewhere in the LocalAI tree. Dockerfile.golang calls it from a layer that +## copies in this Makefile and nothing else, which keeps the multi-minute ggml +## compile in the registry layer cache across builds whose only change is on the +## Go side. See .agents/ci-caching.md. +.PHONY: engine +engine: $(VARIANT_TARGETS) + depth-anything-cpp: main.go godepthanythingcpp.go $(VARIANT_TARGETS) CGO_ENABLED=0 $(GOCMD) build -tags "$(GO_TAGS)" -o depth-anything-cpp ./