mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 01:39:34 +08:00
add makefile
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,3 +11,4 @@ dist
|
|||||||
beszel/cmd/hub/hub
|
beszel/cmd/hub/hub
|
||||||
beszel/cmd/agent/agent
|
beszel/cmd/agent/agent
|
||||||
node_modules
|
node_modules
|
||||||
|
beszel/build
|
||||||
|
35
beszel/Makefile
Normal file
35
beszel/Makefile
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Default OS/ARCH values
|
||||||
|
OS ?= $(shell go env GOOS)
|
||||||
|
ARCH ?= $(shell go env GOARCH)
|
||||||
|
# Skip building the web UI if true
|
||||||
|
SKIP_WEB ?= false
|
||||||
|
|
||||||
|
.PHONY: tidy build-agent build-hub build clean lint
|
||||||
|
.DEFAULT_GOAL := build
|
||||||
|
|
||||||
|
tidy:
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
build-web-ui:
|
||||||
|
@if command -v bun >/dev/null 2>&1; then \
|
||||||
|
bun install --cwd ./site && \
|
||||||
|
bun run --cwd ./site build; \
|
||||||
|
else \
|
||||||
|
npm install --prefix ./site && \
|
||||||
|
npm run --prefix ./site build; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
build-agent: tidy
|
||||||
|
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o ./build/beszel-agent_$(OS)_$(ARCH) -ldflags "-w -s" beszel/cmd/agent
|
||||||
|
|
||||||
|
build-hub: tidy $(if $(filter false,$(SKIP_WEB)),build-web-ui)
|
||||||
|
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o ./build/beszel_$(OS)_$(ARCH) -ldflags "-w -s" beszel/cmd/hub
|
||||||
|
|
||||||
|
build: build-agent build-hub
|
||||||
|
|
||||||
|
clean:
|
||||||
|
go clean
|
||||||
|
rm -rf ./build
|
||||||
|
|
||||||
|
lint:
|
||||||
|
golangci-lint run
|
Binary file not shown.
28
readme.md
28
readme.md
@@ -258,13 +258,31 @@ Pausing/unpausing the agent for longer than one minute will result in incomplete
|
|||||||
|
|
||||||
Both the hub and agent are written in Go, so you can easily build them yourself, or cross-compile for different platforms. Please [install Go](https://go.dev/doc/install) first if you haven't already.
|
Both the hub and agent are written in Go, so you can easily build them yourself, or cross-compile for different platforms. Please [install Go](https://go.dev/doc/install) first if you haven't already.
|
||||||
|
|
||||||
### Prepare dependencies
|
### Using Makefile
|
||||||
|
|
||||||
|
Run `make` in `/beszel`. This creates a `build` directory containing the binaries.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd beszel && make
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also build for different platforms:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make OS=freebsd ARCH=arm64
|
||||||
|
```
|
||||||
|
|
||||||
|
See a list of valid options by running `go tool dist list`.
|
||||||
|
|
||||||
|
### Manual compilation
|
||||||
|
|
||||||
|
#### Prepare dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd beszel && go mod tidy
|
cd beszel && go mod tidy
|
||||||
```
|
```
|
||||||
|
|
||||||
### Agent
|
#### Agent
|
||||||
|
|
||||||
Go to `beszel/cmd/agent` and run the following command to create a binary in the current directory:
|
Go to `beszel/cmd/agent` and run the following command to create a binary in the current directory:
|
||||||
|
|
||||||
@@ -272,7 +290,7 @@ Go to `beszel/cmd/agent` and run the following command to create a binary in the
|
|||||||
CGO_ENABLED=0 go build -ldflags "-w -s" .
|
CGO_ENABLED=0 go build -ldflags "-w -s" .
|
||||||
```
|
```
|
||||||
|
|
||||||
### Hub
|
#### Hub
|
||||||
|
|
||||||
The hub embeds the web UI in the binary, so you must build the website first. I use [Bun](https://bun.sh/), but you may use Node.js if you prefer:
|
The hub embeds the web UI in the binary, so you must build the website first. I use [Bun](https://bun.sh/), but you may use Node.js if you prefer:
|
||||||
|
|
||||||
@@ -288,7 +306,7 @@ Then in `beszel/cmd/hub`:
|
|||||||
CGO_ENABLED=0 go build -ldflags "-w -s" .
|
CGO_ENABLED=0 go build -ldflags "-w -s" .
|
||||||
```
|
```
|
||||||
|
|
||||||
### Cross-compiling
|
#### Cross-compiling
|
||||||
|
|
||||||
You can cross-compile for different platforms using the `GOOS` and `GOARCH` environment variables.
|
You can cross-compile for different platforms using the `GOOS` and `GOARCH` environment variables.
|
||||||
|
|
||||||
@@ -298,7 +316,7 @@ For example, to build for FreeBSD ARM64:
|
|||||||
GOOS=freebsd GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-w -s" .
|
GOOS=freebsd GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-w -s" .
|
||||||
```
|
```
|
||||||
|
|
||||||
You can see a list of valid options by running `go tool dist list`.
|
See a list of valid options by running `go tool dist list`.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user