-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
53 lines (40 loc) · 1.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Makefile for a Gin-based Golang project using gox for cross-compilation
# Project Name
BINARY_NAME=fern
# Go related variables.
GOBASE=$(shell pwd)
GOBIN=$(GOBASE)/bin
GOPKG=$(GOBASE)
# Go build and run commands
.PHONY: all build run clean cross-compile docker-build docker-run
all: build
build:
@echo "🚀 Building..."
@GOBIN=$(GOBIN) go build -o $(GOBIN)/$(BINARY_NAME) $(GOPKG)
run:
@echo "Running..."
@GOBIN=$(GOBIN) ./bin/$(BINARY_NAME)
clean:
@echo "🧹 Cleaning..."
@GOBIN=$(GOBIN) go clean
@rm -f $(GOBIN)/$(BINARY_NAME)
# Cross-compilation with gox
cross-compile:
@echo "🛠️ Cross compiling for Linux and Mac..."
@gox -osarch="linux/amd64 darwin/amd64" -output "$(GOBIN)/$(BINARY_NAME)_{{.OS}}_{{.Arch}}" $(GOPKG)
# Testing
test:
@echo "🧪 Running Tests..."
@go test $(TEST_FLAGS) -coverprofile=profile.cov ./...
docker-build: cross-compile
@echo "🐳 Building Local Docker image..."
@docker build -t fern-app . -f Dockerfile-local
docker-run-local: docker-build
@echo "🏃 Running application in Docker..."
@docker run -it -p 8080:8080 fern-app
docker-build-multi-arch:
@echo "Building multi arch docker image and pushing..."
@docker buildx build --platform linux/amd64,linux/arm64,linux/arm64/v8 -t anoop2811/fern-reporter:latest --push .
cover:
@echo "📊 Running Tests with Coverage..."
@go test -coverprofile=profile.cov ./...