Skip to content

Commit f8a8cf3

Browse files
authored
feat(launcher): add LocalAI launcher app (#6127)
* Add launcher (WIP) Signed-off-by: Ettore Di Giacinto <[email protected]> * Update gomod Signed-off-by: Ettore Di Giacinto <[email protected]> * Cleanup, focus on systray Signed-off-by: Ettore Di Giacinto <[email protected]> * Separate launcher from main Signed-off-by: Ettore Di Giacinto <[email protected]> * Add a way to identify the binary version Signed-off-by: Ettore Di Giacinto <[email protected]> * Implement save config, and start on boot Signed-off-by: Ettore Di Giacinto <[email protected]> * Small fixups Signed-off-by: Ettore Di Giacinto <[email protected]> * Save installed version as metadata Signed-off-by: Ettore Di Giacinto <[email protected]> * Stop LocalAI on quit Signed-off-by: Ettore Di Giacinto <[email protected]> * Fix goreleaser Signed-off-by: Ettore Di Giacinto <[email protected]> * Check first if binary is there Signed-off-by: Ettore Di Giacinto <[email protected]> * do not show version if we don't have it Signed-off-by: Ettore Di Giacinto <[email protected]> * Try to build on CI Signed-off-by: Ettore Di Giacinto <[email protected]> * use fyne package Signed-off-by: Ettore Di Giacinto <[email protected]> * Add to release Signed-off-by: Ettore Di Giacinto <[email protected]> * Fixups Signed-off-by: Ettore Di Giacinto <[email protected]> * Fyne.Do Signed-off-by: Ettore Di Giacinto <[email protected]> * show WEBUI button only if LocalAI is started Signed-off-by: Ettore Di Giacinto <[email protected]> * Default to localhost Signed-off-by: Ettore Di Giacinto <[email protected]> * CI Signed-off-by: Ettore Di Giacinto <[email protected]> * Show rel notes Signed-off-by: Ettore Di Giacinto <[email protected]> * Update logo Signed-off-by: Ettore Di Giacinto <[email protected]> * Small improvements and fix tests Signed-off-by: Ettore Di Giacinto <[email protected]> * Try to fix e2e tests Signed-off-by: Ettore Di Giacinto <[email protected]> --------- Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 0fc88b3 commit f8a8cf3

File tree

20 files changed

+3267
-20
lines changed

20 files changed

+3267
-20
lines changed

.github/workflows/build-test.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,47 @@ jobs:
2121
- name: Run GoReleaser
2222
run: |
2323
make dev-dist
24+
launcher-build-darwin:
25+
runs-on: macos-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v5
29+
with:
30+
fetch-depth: 0
31+
- name: Set up Go
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: 1.23
35+
- name: Build launcher for macOS ARM64
36+
run: |
37+
make build-launcher-darwin
38+
ls -liah dist
39+
- name: Upload macOS launcher artifacts
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: launcher-macos
43+
path: dist/
44+
retention-days: 30
45+
46+
launcher-build-linux:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v5
51+
with:
52+
fetch-depth: 0
53+
- name: Set up Go
54+
uses: actions/setup-go@v5
55+
with:
56+
go-version: 1.23
57+
- name: Build launcher for Linux
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev libxkbcommon-dev
61+
make build-launcher-linux
62+
- name: Upload Linux launcher artifacts
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: launcher-linux
66+
path: local-ai-launcher-linux.tar.xz
67+
retention-days: 30

.github/workflows/release.yaml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,52 @@ jobs:
2323
version: v2.11.0
2424
args: release --clean
2525
env:
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
launcher-build-darwin:
28+
runs-on: macos-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v5
32+
with:
33+
fetch-depth: 0
34+
- name: Set up Go
35+
uses: actions/setup-go@v5
36+
with:
37+
go-version: 1.23
38+
- name: Build launcher for macOS ARM64
39+
run: |
40+
make build-launcher-darwin
41+
- name: Upload DMG to Release
42+
uses: actions/upload-release-asset@v1
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
with:
46+
url: ${{ github.event.release.upload_url }}
47+
asset_path: ./dist/LocalAI-Launcher.dmg
48+
asset_name: LocalAI.dmg
49+
asset_content_type: application/octet-stream
50+
launcher-build-linux:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v5
55+
with:
56+
fetch-depth: 0
57+
- name: Set up Go
58+
uses: actions/setup-go@v5
59+
with:
60+
go-version: 1.23
61+
- name: Build launcher for Linux
62+
run: |
63+
sudo apt-get update
64+
sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev libxkbcommon-dev
65+
make build-launcher-linux
66+
- name: Upload Linux launcher artifacts
67+
uses: actions/upload-release-asset@v1
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
url: ${{ github.event.release.upload_url }}
72+
asset_path: ./local-ai-launcher-linux.tar.xz
73+
asset_name: LocalAI-Launcher-linux.tar.xz
74+
asset_content_type: application/octet-stream

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ go-bert
2424

2525
# LocalAI build binary
2626
LocalAI
27-
local-ai
27+
/local-ai
2828
# prevent above rules from omitting the helm chart
2929
!charts/*
3030
# prevent above rules from omitting the api/localai folder

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source:
88
enabled: true
99
name_template: '{{ .ProjectName }}-{{ .Tag }}-source'
1010
builds:
11-
-
11+
- main: ./cli/local-ai
1212
env:
1313
- CGO_ENABLED=0
1414
ldflags:

Makefile

Lines changed: 28 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) ./cli/launcher
103+
104+
build-all: build build-launcher ## Build both server and launcher
94105

95106
dev-dist:
96107
$(GORELEASER) build --snapshot --clean
@@ -507,3 +518,19 @@ docs-clean:
507518
.PHONY: docs
508519
docs: docs/static/gallery.html
509520
cd docs && hugo serve
521+
522+
########################################################
523+
## Platform-specific builds
524+
########################################################
525+
526+
## fyne cross-platform build
527+
build-launcher-darwin: build-launcher
528+
go run github.com/tiagomelo/macos-dmg-creator/cmd/createdmg@latest \
529+
--appName "LocalAI" \
530+
--appBinaryPath "$(LAUNCHER_BINARY_NAME)" \
531+
--bundleIdentifier "com.localai.launcher" \
532+
--iconPath "core/http/static/logo.png" \
533+
--outputDir "dist/"
534+
535+
build-launcher-linux:
536+
cd cli/launcher && go run fyne.io/tools/cmd/fyne@latest package -os linux -icon ../../core/http/static/logo.png --executable $(LAUNCHER_BINARY_NAME)-linux && mv launcher.tar.xz ../../$(LAUNCHER_BINARY_NAME)-linux.tar.xz

cli/launcher/icon.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package main
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)