Template
1
0
Go/Makefile
2025-02-24 08:59:31 +01:00

70 lines
2.0 KiB
Makefile

.DEFAULT_GOAL := build
BINARY_NAME := ${REPO_NAME}
LDFLAGS := -s -w
arkanum-install:
@echo "🤖 Installing required frameworks and runtimes with arkanum..."
@arkanum install golang
@arkanum install nodejs
@echo "🚩 step done."
install:
@echo "🤖 Installing frontend dependencies...(npm)"
cd web && npm install
@echo "🤖 Install backend dependencies...(golang)"
go mod tidy
@echo "🤖 Install global helpers..."
npm install --global prettier
@echo "🚩 step done."
lint:
@echo "🤖 Running prettier linter in check mode..."
pretier -c .
prettier:
@echo "🤖 Running prettier linter in write mode..."
prettier -w .
clean:
@echo "🤖 Cleaning go cache..."
@go clean
@echo "🤖 Cleanig web / pb_public files..."
@cd web && npm run clean
@echo "🤖 Cleaning dist binaries..."
@rm dist/${BINARY_NAME}-* || echo "Files already removed or not present. Ignore this error."
@echo "🚩 step done."
build-frontend:
@echo "📦 Building frontend artifacts..."
@cd web && npm run build
@echo "🚩 step done."
frontend-dev:
@echo "🚀 Starting frontend dev server..."
@cd web && npm run dev
build-linux: clean build-frontend
@echo "📦 Building linux binary..."
@CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -a -v ldflags= '${LD_FLAGS}' -o dist/${BINARY_NAME}-linux-amd64 .
@echo "🚩 step done."
build-win: clean build-frontend
@echo "📦 Building windows binary..."
@CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -a -v ldflags= '${LD_FLAGS}' -o dist/${BINARY_NAME}-win-amd64 .
@echo "🚩 step done."
build: build-linux build-win
@ls -lh dist/
@echo "🏁 done."
dev: clean build-frontend
@echo "📦 Building linux dev binary..."
@CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -tags dev -v ldflags '${LD_FLAGS}' -o dist/${BINARY_NAME}-dev .
@echo "🚀 Starting dev server..."
dist/${BINARY_NAME}-dev serve --dev --http="0.0.0.0:1313"
serve:
@echo "🚀 Starting dev server in prod mode..."
dist/${BINARY_NAME}-linux-amd64 serve --http="0.0.0.0:1313"