Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary Version #50

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ dist-ssr
*.sw?

doc.json
nanokabel
nanokabel

bin
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ pnpm --filter "./packages/**" publish --dry-run
pnpm --filter "./packages/**" publish --access public
```

## Experimental "Desktop" Version

There is an experimental "Desktop" version, which serves the built site as a binary (<10MB).
It's without UI, so you still have to open it in your browser, but it's self-contained, so it works offline and all code is baked into the binary.

```sh
pnpm build # build site to website/dist
# make sure you have go installed
pnpm build-bin # builds all binaries
./bin/kabelsalat-darwin-arm64 # run site
# go to http://localhost:8080
```

Currently it builds Linux and MacOS binaries, but adding others should be trivial.

## Packages

This project is a monorepo with the following packages:
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module server

go 1.23.2
26 changes: 26 additions & 0 deletions kabelsalat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"embed"
"io/fs"
"log"
"net/http"
)

//go:embed website/dist/*
var files embed.FS

func main() {
publicFiles, err := fs.Sub(files, "website/dist")
if err != nil {
log.Fatal(err)
}
fs := http.FileServer(http.FS(publicFiles))

http.Handle("/", fs)
log.Println("Serving files on http://localhost:8080")
err = http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"dev": "cd website && pnpm dev",
"build": "cd website && pnpm build",
"preview": "cd website && pnpm preview",
"test": "cd test && pnpm test"
"test": "cd test && pnpm test",
"build-darwin-arm64": "GOOS=darwin GOARCH=arm64 go build -o bin/kabelsalat-darwin-arm64",
"build-darwin-amd64": "GOOS=darwin GOARCH=amd64 go build -o bin/kabelsalat-darwin-amd64",
"build-linux-amd64": "GOOS=linux GOARCH=amd64 go build -o bin/kabelsalat-linux-amd64",
"build-bin": "npm run build-darwin-arm64 && npm run build-linux-amd64"
},
"author": "Felix Roos <[email protected]>",
"license": "AGPL-3.0-or-later",
Expand Down
Loading