edgeboxctl/Makefile

115 lines
3.2 KiB
Makefile
Raw Permalink Normal View History

.DEFAULT_GOAL := build
2021-02-11 21:21:22 +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
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
2021-02-11 21:21:22 +01:00
build-all:
@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
GOOS=linux GOARCH=arm make build
2021-02-11 21:21:22 +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
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
build-amd64:
GOOS=linux GOARCH=amd64 RELEASE=prod make build
2021-02-11 21:21:22 +01:00
build:
@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
@echo "\n🟢 Build task completed\n"
2021-02-11 21:21:22 +01:00
clean:
@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
@echo "\n🟢 Clean task completed\n"
2021-06-08 14:13:22 +02:00
test:
go test -tags=unit -timeout=600s -v ./...
test-with-coverage:
go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out
run:
@echo "\n🚀 Running edgeboxctl\n"
./bin/edgeboxctl-${GOOS}-${GOARCH}
install:
@echo "📦 Installing edgeboxctl service (${RELEASE}) for ${GOOS} (${GOARCH})\n"
@echo "🚧 Stopping edgeboxctl service if it is running"
sudo systemctl stop edgeboxctl || true
@echo "\n🗑 Removing old edgeboxctl binary and service"
sudo rm -rf /usr/local/bin/edgeboxctl /usr/local/sbin/edgeboctl /lib/systemd/system/edgeboxctl.service
@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
@echo "\n🚚 Copying edgeboxctl service to /lib/systemd/system"
sudo cp ./edgeboxctl.service /lib/systemd/system/edgeboxctl.service
sudo systemctl daemon-reload
@echo "\n 🚀 To start edgeboxctl run: make start"
@echo "🟢 Edgeboxctl installed successfully\n"
install-prod: build-prod install
install-cloud: build-cloud install
install-arm64: build-arm64 install
install-armhf: build-armhf install
install-amd64: build-amd64 install
start:
@echo "\n 🚀 Starting edgeboxctl service\n"
systemctl start edgeboxctl
@echo "\n 🟢 Edgebox service started\n"
stop:
@echo "\n✋ Stopping edgeboxctl service\n"
systemctl stop edgeboxctl
@echo "\n 🟢 Edgebox service stopped\n"
restart:
@echo "\n💫 Restarting edgeboxctl service\n"
systemctl restart edgeboxctl
@echo "\n 🟢 Edgebox service restarted\n"
status:
@echo "\n edgeboxctl Service Info:\n"
systemctl status edgeboxctl
log:
@echo "\n📰 edgeboxctl service logs:\n"
journalctl -fu edgeboxctl