Skip to content

Commit 5ed610d

Browse files
committed
Add launcher (WIP)
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent d04bd47 commit 5ed610d

File tree

13 files changed

+2104
-114
lines changed

13 files changed

+2104
-114
lines changed

Makefile

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ GOCMD=go
22
GOTEST=$(GOCMD) test
33
GOVET=$(GOCMD) vet
44
BINARY_NAME=local-ai
5+
LAUNCHER_BINARY_NAME=local-ai-launcher
56

67
GORELEASER?=
78

@@ -90,7 +91,17 @@ build: protogen-go install-go-tools ## Build the project
9091
$(info ${GREEN}I LD_FLAGS: ${YELLOW}$(LD_FLAGS)${RESET})
9192
$(info ${GREEN}I UPX: ${YELLOW}$(UPX)${RESET})
9293
rm -rf $(BINARY_NAME) || true
93-
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./
94+
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./cli/local-ai
95+
96+
build-launcher: ## Build the launcher application
97+
$(info ${GREEN}I local-ai launcher build info:${RESET})
98+
$(info ${GREEN}I BUILD_TYPE: ${YELLOW}$(BUILD_TYPE)${RESET})
99+
$(info ${GREEN}I GO_TAGS: ${YELLOW}$(GO_TAGS)${RESET})
100+
$(info ${GREEN}I LD_FLAGS: ${YELLOW}$(LD_FLAGS)${RESET})
101+
rm -rf $(LAUNCHER_BINARY_NAME) || true
102+
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(LAUNCHER_BINARY_NAME) ./
103+
104+
build-all: build build-launcher ## Build both server and launcher
94105

95106
dev-dist:
96107
$(GORELEASER) build --snapshot --clean
@@ -499,3 +510,59 @@ docs-clean:
499510
.PHONY: docs
500511
docs: docs/static/gallery.html
501512
cd docs && hugo serve
513+
514+
########################################################
515+
## Platform-specific builds
516+
########################################################
517+
518+
# macOS builds
519+
build-launcher-darwin-amd64: ## Build launcher for macOS AMD64
520+
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GOCMD) build -ldflags "$(LD_FLAGS)" -o $(LAUNCHER_BINARY_NAME)-darwin-amd64 ./
521+
522+
build-launcher-darwin-arm64: ## Build launcher for macOS ARM64
523+
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 $(GOCMD) build -ldflags "$(LD_FLAGS)" -o $(LAUNCHER_BINARY_NAME)-darwin-arm64 ./
524+
525+
# Linux builds
526+
build-launcher-linux-amd64: ## Build launcher for Linux AMD64
527+
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 $(GOCMD) build -ldflags "$(LD_FLAGS)" -o $(LAUNCHER_BINARY_NAME)-linux-amd64 ./
528+
529+
build-launcher-linux-arm64: ## Build launcher for Linux ARM64
530+
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 $(GOCMD) build -ldflags "$(LD_FLAGS)" -o $(LAUNCHER_BINARY_NAME)-linux-arm64 ./
531+
532+
# Windows builds
533+
build-launcher-windows-amd64: ## Build launcher for Windows AMD64
534+
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 $(GOCMD) build -ldflags "$(LD_FLAGS)" -o $(LAUNCHER_BINARY_NAME)-windows-amd64.exe ./
535+
536+
# macOS DMG creation (requires macOS)
537+
create-dmg: build-launcher-darwin-amd64 build-launcher-darwin-arm64 ## Create macOS DMG
538+
ifeq ($(OS),Darwin)
539+
@echo "Creating macOS DMG package..."
540+
mkdir -p dist/LocalAI-Launcher
541+
cp $(LAUNCHER_BINARY_NAME)-darwin-$(shell uname -m) dist/LocalAI-Launcher/LocalAI-Launcher
542+
ln -sf /Applications dist/LocalAI-Launcher/Applications
543+
hdiutil create -volname "LocalAI Launcher" -srcfolder dist/LocalAI-Launcher -ov -format UDZO dist/LocalAI-Launcher.dmg
544+
rm -rf dist/LocalAI-Launcher
545+
@echo "DMG created: dist/LocalAI-Launcher.dmg"
546+
else
547+
@echo "DMG creation requires macOS"
548+
endif
549+
550+
# Linux package creation
551+
create-linux-package: build-launcher-linux-amd64 build-launcher-linux-arm64 ## Create Linux packages
552+
@echo "Creating Linux packages..."
553+
mkdir -p dist/linux-amd64/usr/local/bin
554+
mkdir -p dist/linux-arm64/usr/local/bin
555+
cp $(LAUNCHER_BINARY_NAME)-linux-amd64 dist/linux-amd64/usr/local/bin/local-ai-launcher
556+
cp $(LAUNCHER_BINARY_NAME)-linux-arm64 dist/linux-arm64/usr/local/bin/local-ai-launcher
557+
chmod +x dist/linux-amd64/usr/local/bin/local-ai-launcher
558+
chmod +x dist/linux-arm64/usr/local/bin/local-ai-launcher
559+
cd dist && tar -czf LocalAI-Launcher-linux-amd64.tar.gz -C linux-amd64 .
560+
cd dist && tar -czf LocalAI-Launcher-linux-arm64.tar.gz -C linux-arm64 .
561+
rm -rf dist/linux-amd64 dist/linux-arm64
562+
@echo "Linux packages created in dist/"
563+
564+
# Cross-platform builds
565+
build-launcher-all: build-launcher-darwin-amd64 build-launcher-darwin-arm64 build-launcher-linux-amd64 build-launcher-linux-arm64 build-launcher-windows-amd64 ## Build launcher for all platforms
566+
567+
# Package creation for all platforms
568+
package-launcher: build-launcher-all create-dmg create-linux-package ## Create packages for all platforms

cli/launcher/icon.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package launcher
2+
3+
import (
4+
_ "embed"
5+
6+
"fyne.io/fyne/v2"
7+
)
8+
9+
//go:embed logo.png
10+
var logoData []byte
11+
12+
// resourceIconPng is the LocalAI logo icon
13+
var resourceIconPng = &fyne.StaticResource{
14+
StaticName: "logo.png",
15+
StaticContent: logoData,
16+
}

0 commit comments

Comments
 (0)