Improved Makefile with info and install + build processes
parent
c5cfe4bdbc
commit
0e579c19da
48
Makefile
48
Makefile
|
@ -10,8 +10,15 @@ GOARCH := $(shell go env GOARCH)
|
||||||
|
|
||||||
|
|
||||||
build-all:
|
build-all:
|
||||||
GOOS=linux GOARCH=amd64 make build
|
@echo "\n🏗️ Building all architectures and release modes"
|
||||||
GOOS=linux GOARCH=arm make build
|
@echo "🟡 This will build all supported architectures and release combinations. It can take a while...\n"
|
||||||
|
|
||||||
|
GOARCH=amd64 make build
|
||||||
|
GOARCH=arm make build
|
||||||
|
RELEASE=prod make build
|
||||||
|
RELEASE=cloud make build
|
||||||
|
|
||||||
|
@echo "\n🟢 All builds completed and available at ./bin/ \n"
|
||||||
|
|
||||||
build-prod:
|
build-prod:
|
||||||
GOOS=linux GOARCH=arm RELEASE=prod make build
|
GOOS=linux GOARCH=arm RELEASE=prod make build
|
||||||
|
@ -30,17 +37,25 @@ build-amd64:
|
||||||
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@echo "Building ${GOOS}-${GOARCH}"
|
@echo "\n🏗️ Building edgeboxctl (${RELEASE} release) on ${GOOS} (${GOARCH})"
|
||||||
|
@echo "📦 Binary will be saved in ./${BUILD_DIR}/edgeboxctl-${GOOS}-${GOARCH}\n"
|
||||||
|
|
||||||
GOOS=${GOOS} GOARCH=${GOARCH} go build \
|
GOOS=${GOOS} GOARCH=${GOARCH} go build \
|
||||||
-trimpath -ldflags "-s -w -X ${PROJECT}/internal/diagnostics.Version=${RELEASE} \
|
-trimpath -ldflags "-s -w -X ${PROJECT}/internal/diagnostics.Version=${RELEASE} \
|
||||||
-X ${PROJECT}/internal/diagnostics.Commit=${COMMIT} \
|
-X ${PROJECT}/internal/diagnostics.Commit=${COMMIT} \
|
||||||
-X ${PROJECT}/internal/diagnostics.BuildDate=${BUILD_DATE}" \
|
-X ${PROJECT}/internal/diagnostics.BuildDate=${BUILD_DATE}" \
|
||||||
-o bin/edgeboxctl-${GOOS}-${GOARCH} ${PROJECT}/cmd/edgeboxctl
|
-o bin/edgeboxctl-${GOOS}-${GOARCH} ${PROJECT}/cmd/edgeboxctl
|
||||||
|
|
||||||
|
@echo "\n🟢 Build task completed\n"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@echo "🧹 Cleaning build directory and go cache\n"
|
||||||
|
|
||||||
rm -rf ${BUILD_DIR}
|
rm -rf ${BUILD_DIR}
|
||||||
go clean
|
go clean
|
||||||
|
|
||||||
|
@echo "\n🟢 Clean task completed\n"
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -tags=unit -timeout=600s -v ./...
|
go test -tags=unit -timeout=600s -v ./...
|
||||||
|
|
||||||
|
@ -48,14 +63,24 @@ test-with-coverage:
|
||||||
go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out
|
go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
@echo "📦 Installing edgeboxctl service (${RELEASE}) for ${GOOS} (${GOARCH})\n"
|
||||||
|
|
||||||
|
@echo "🚧 Stopping edgeboxctl service if it is running"
|
||||||
sudo systemctl stop edgeboxctl || true
|
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
|
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"
|
||||||
sudo cp ./bin/edgeboxctl-${GOOS}-${GOARCH} /usr/local/bin/edgeboxctl
|
sudo cp ./bin/edgeboxctl-${GOOS}-${GOARCH} /usr/local/bin/edgeboxctl
|
||||||
sudo cp ./bin/edgeboxctl-${GOOS}-${GOARCH} /usr/local/sbin/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 cp ./edgeboxctl.service /lib/systemd/system/edgeboxctl.service
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
@echo "Edgeboxctl installed successfully"
|
|
||||||
@echo "To start edgeboxctl run: systemctl start edgeboxctl"
|
@echo "\n 🚀 To start edgeboxctl run: make start"
|
||||||
|
@echo "🟢 Edgeboxctl installed successfully\n"
|
||||||
|
|
||||||
install-prod: build-prod install
|
install-prod: build-prod install
|
||||||
install-cloud: build-cloud install
|
install-cloud: build-cloud install
|
||||||
|
@ -64,13 +89,24 @@ install-armhf: build-armhf install
|
||||||
install-amd64: build-amd64 install
|
install-amd64: build-amd64 install
|
||||||
|
|
||||||
start:
|
start:
|
||||||
|
@echo "\n 🚀 Starting edgeboxctl service\n"
|
||||||
systemctl start edgeboxctl
|
systemctl start edgeboxctl
|
||||||
|
@echo "\n 🟢 Edgebox service started\n"
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
|
@echo "\n✋ Stopping edgeboxctl service\n"
|
||||||
systemctl stop edgeboxctl
|
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:
|
status:
|
||||||
|
@echo "\nℹ️ edgeboxctl Service Info:\n"
|
||||||
systemctl status edgeboxctl
|
systemctl status edgeboxctl
|
||||||
|
|
||||||
log: start
|
log:
|
||||||
|
@echo "\n📰 edgeboxctl service logs:\n"
|
||||||
journalctl -fu edgeboxctl
|
journalctl -fu edgeboxctl
|
||||||
|
|
Loading…
Reference in New Issue