-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (65 loc) · 2.05 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Makefile for building the project
.PHONY: proto docker test lint vet build run
# Use /bin/bash as the shell
SHELL := /bin/bash
# Default target
.DEFAULT_GOAL := help
# Proto files
PROTO_FILES := echo.proto
# Go application name
APP_NAME := echo-app
# Docker image name
DOCKER_IMAGE := ghcr.io/philipschmid/$(APP_NAME)
# Help target
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
# Proto target
proto: ## Generate and update the proto files
@echo "Generating proto files..."
protoc --go_out=. --go-grpc_out=. $(PROTO_FILES)
@echo "Proto files generated."
# Docker target
docker: proto ## Build the Docker image
@echo "Building Docker image..."
docker buildx build --platform linux/amd64,linux/arm64 --tag $(DOCKER_IMAGE) .
@echo "Docker image built: $(DOCKER_IMAGE)"
# Test target
test: ## Run tests
@echo "Running tests..."
go test -v ./...
@echo "Tests completed."
# Lint target
lint: ## Run golangci-lint
@echo "Running golangci-lint..."
golangci-lint run
@echo "golangci-lint completed."
# Vet target
vet: ## Run go vet
@echo "Running go vet..."
go vet ./...
@echo "go vet completed."
# Build target
build: lint vet test ## Build the Go application
@echo "Building the Go application..."
go build -ldflags="-s -w" -a -o $(APP_NAME) .
@echo "Build completed."
# Run target
run: ## Run the Go application
@echo "Running the Go application..."
./$(APP_NAME)
# Run all target
run-all: ## Run the Go application with all listeners
@echo "Running the Go application..."
./$(APP_NAME) --tls --tcp --grpc --quic
# Run all debug mode target
run-all-debug: ## Run the Go application with all listeners in debug mode
@echo "Running the Go application in debug mode..."
./$(APP_NAME) --tls --tcp --grpc --quic --log-level debug
# Clean up build artifcats target
cleanup: ## Clean up build artifacts
@echo "Cleaning up build artifacts"
rm $(APP_NAME)
@echo "Cleaning up build artifacts completed."