-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
54 lines (46 loc) · 1.27 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
# Makefile for building the project
# Use /bin/bash as the shell
SHELL := /bin/bash
# Default target
.DEFAULT_GOAL := help
# Go application name
APP_NAME := echoserver-udp
# Help target
.PHONY: help
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
# Docker target
.PHONY: docker
docker: ## Build the Docker image
@echo "Building Docker image..."
docker buildx build \
--platform linux/amd64,linux/arm64 \
--build-arg BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
--build-arg VCS_REF=$(shell git rev-parse --short HEAD) \
--tag quay.io/cilium/$(APP_NAME) \
.
@echo "Docker image built: quay.io/cilium/$(APP_NAME)"
# Build target
.PHONY: build
build: ## Build the Go application
@echo "Building the Go application..."
go build \
-ldflags="-s -w" \
-a \
-o $(APP_NAME) \
main.go
@echo "Build completed."
# Run target
.PHONY: run
run: ## Run the Go application
@echo "Running the Go application..."
./$(APP_NAME)
# Clean up build artifacts target
.PHONY: cleanup
cleanup: ## Clean up build artifacts
@echo "Cleaning up build artifacts..."
rm -f $(APP_NAME)
@echo "Cleaning up build artifacts completed."