2023-11-19 21:33:18 +01:00
|
|
|
|
.DEFAULT_GOAL := build
|
2021-02-11 21:21:22 +01:00
|
|
|
|
|
2023-11-19 21:33:18 +01:00
|
|
|
|
PROJECT ?= github.com/edgebox-iot/edgeboxctl
|
2021-02-11 21:21:22 +01:00
|
|
|
|
RELEASE ?= dev
|
|
|
|
|
COMMIT := $(shell git rev-parse --short HEAD)
|
|
|
|
|
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
|
|
|
|
|
BUILD_DIR = bin
|
2023-11-19 21:33:18 +01:00
|
|
|
|
GOOS := $(shell go env GOOS)
|
|
|
|
|
GOARCH := $(shell go env GOARCH)
|
|
|
|
|
|
2021-02-11 21:21:22 +01:00
|
|
|
|
|
|
|
|
|
build-all:
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n🏗️ Building all architectures for ${RELEASE} mode"
|
|
|
|
|
@echo "🟡 This will build all supported architectures and release combinations. It can take a while...\n"
|
|
|
|
|
|
2021-02-11 21:21:22 +01:00
|
|
|
|
GOOS=linux GOARCH=amd64 make build
|
2021-02-12 18:22:03 +01:00
|
|
|
|
GOOS=linux GOARCH=arm make build
|
2021-02-11 21:21:22 +01:00
|
|
|
|
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n🟢 All builds completed and available at ./bin/ \n"
|
|
|
|
|
|
2021-03-04 13:43:49 +01:00
|
|
|
|
build-prod:
|
2021-03-04 15:06:48 +01:00
|
|
|
|
GOOS=linux GOARCH=arm RELEASE=prod make build
|
2021-03-04 13:43:49 +01:00
|
|
|
|
|
2022-02-06 15:37:50 +01:00
|
|
|
|
build-cloud:
|
|
|
|
|
GOOS=linux GOARCH=amd64 RELEASE=cloud make build
|
|
|
|
|
|
2023-04-17 20:28:06 +02:00
|
|
|
|
build-arm64:
|
|
|
|
|
GOOS=linux GOARCH=arm64 RELEASE=prod make build
|
|
|
|
|
|
|
|
|
|
build-armhf:
|
|
|
|
|
GOOS=linux GOARCH=arm RELEASE=prod make build
|
|
|
|
|
|
2023-11-05 11:47:42 +01:00
|
|
|
|
build-amd64:
|
|
|
|
|
GOOS=linux GOARCH=amd64 RELEASE=prod make build
|
|
|
|
|
|
|
|
|
|
|
2021-02-11 21:21:22 +01:00
|
|
|
|
build:
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n🏗️ Building edgeboxctl (${RELEASE} release) on ${GOOS} (${GOARCH})"
|
|
|
|
|
@echo "📦 Binary will be saved in ./${BUILD_DIR}/edgeboxctl-${GOOS}-${GOARCH}\n"
|
|
|
|
|
|
2021-02-11 21:21:22 +01:00
|
|
|
|
GOOS=${GOOS} GOARCH=${GOARCH} go build \
|
|
|
|
|
-trimpath -ldflags "-s -w -X ${PROJECT}/internal/diagnostics.Version=${RELEASE} \
|
|
|
|
|
-X ${PROJECT}/internal/diagnostics.Commit=${COMMIT} \
|
|
|
|
|
-X ${PROJECT}/internal/diagnostics.BuildDate=${BUILD_DATE}" \
|
2021-03-04 13:48:25 +01:00
|
|
|
|
-o bin/edgeboxctl-${GOOS}-${GOARCH} ${PROJECT}/cmd/edgeboxctl
|
2021-02-11 21:21:22 +01:00
|
|
|
|
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n🟢 Build task completed\n"
|
|
|
|
|
|
2021-02-11 21:21:22 +01:00
|
|
|
|
clean:
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "🧹 Cleaning build directory and go cache\n"
|
|
|
|
|
|
2021-02-11 21:45:08 +01:00
|
|
|
|
rm -rf ${BUILD_DIR}
|
2021-02-11 21:21:22 +01:00
|
|
|
|
go clean
|
2021-06-08 14:13:22 +02:00
|
|
|
|
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n🟢 Clean task completed\n"
|
|
|
|
|
|
2021-06-08 14:13:22 +02:00
|
|
|
|
test:
|
|
|
|
|
go test -tags=unit -timeout=600s -v ./...
|
2021-06-08 22:40:53 +02:00
|
|
|
|
|
|
|
|
|
test-with-coverage:
|
|
|
|
|
go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out
|
2023-03-11 13:58:54 +01:00
|
|
|
|
|
2024-12-07 01:26:45 +01:00
|
|
|
|
run:
|
|
|
|
|
@echo "\n🚀 Running edgeboxctl\n"
|
|
|
|
|
./bin/edgeboxctl-${GOOS}-${GOARCH}
|
|
|
|
|
|
2023-06-10 17:29:54 +02:00
|
|
|
|
install:
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "📦 Installing edgeboxctl service (${RELEASE}) for ${GOOS} (${GOARCH})\n"
|
|
|
|
|
|
|
|
|
|
@echo "🚧 Stopping edgeboxctl service if it is running"
|
2023-11-05 12:19:09 +01:00
|
|
|
|
sudo systemctl stop edgeboxctl || true
|
2024-12-07 01:26:45 +01:00
|
|
|
|
|
|
|
|
|
@echo "\n🗑️ Removing old edgeboxctl binary and service"
|
2023-10-28 18:43:18 +02:00
|
|
|
|
sudo rm -rf /usr/local/bin/edgeboxctl /usr/local/sbin/edgeboctl /lib/systemd/system/edgeboxctl.service
|
2024-12-07 01:26:45 +01:00
|
|
|
|
|
|
|
|
|
@echo "\n🚚 Copying edgeboxctl binary to /usr/local/bin"
|
2023-11-19 21:46:11 +01:00
|
|
|
|
sudo cp ./bin/edgeboxctl-${GOOS}-${GOARCH} /usr/local/bin/edgeboxctl
|
|
|
|
|
sudo cp ./bin/edgeboxctl-${GOOS}-${GOARCH} /usr/local/sbin/edgeboxctl
|
2024-12-07 01:26:45 +01:00
|
|
|
|
|
|
|
|
|
@echo "\n🚚 Copying edgeboxctl service to /lib/systemd/system"
|
2023-03-20 00:54:42 +01:00
|
|
|
|
sudo cp ./edgeboxctl.service /lib/systemd/system/edgeboxctl.service
|
|
|
|
|
sudo systemctl daemon-reload
|
2024-12-07 01:26:45 +01:00
|
|
|
|
|
|
|
|
|
@echo "\n 🚀 To start edgeboxctl run: make start"
|
|
|
|
|
@echo "🟢 Edgeboxctl installed successfully\n"
|
2023-06-10 17:29:54 +02:00
|
|
|
|
|
|
|
|
|
install-prod: build-prod install
|
|
|
|
|
install-cloud: build-cloud install
|
|
|
|
|
install-arm64: build-arm64 install
|
|
|
|
|
install-armhf: build-armhf install
|
2023-11-05 11:47:42 +01:00
|
|
|
|
install-amd64: build-amd64 install
|
2023-06-10 17:29:54 +02:00
|
|
|
|
|
|
|
|
|
start:
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n 🚀 Starting edgeboxctl service\n"
|
2023-06-10 17:29:54 +02:00
|
|
|
|
systemctl start edgeboxctl
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n 🟢 Edgebox service started\n"
|
2023-06-10 17:29:54 +02:00
|
|
|
|
|
|
|
|
|
stop:
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n✋ Stopping edgeboxctl service\n"
|
2023-06-10 17:29:54 +02:00
|
|
|
|
systemctl stop edgeboxctl
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\n 🟢 Edgebox service stopped\n"
|
|
|
|
|
|
|
|
|
|
restart:
|
|
|
|
|
@echo "\n💫 Restarting edgeboxctl service\n"
|
|
|
|
|
systemctl restart edgeboxctl
|
|
|
|
|
@echo "\n 🟢 Edgebox service restarted\n"
|
2023-06-10 17:29:54 +02:00
|
|
|
|
|
2024-11-02 22:42:56 +01:00
|
|
|
|
status:
|
2024-12-07 01:26:45 +01:00
|
|
|
|
@echo "\nℹ️ edgeboxctl Service Info:\n"
|
2024-11-02 22:42:56 +01:00
|
|
|
|
systemctl status edgeboxctl
|
|
|
|
|
|
2024-12-07 01:26:45 +01:00
|
|
|
|
log:
|
|
|
|
|
@echo "\n📰 edgeboxctl service logs:\n"
|
2023-06-10 17:29:54 +02:00
|
|
|
|
journalctl -fu edgeboxctl
|