-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (70 loc) · 1.82 KB
/
Makefile
File metadata and controls
85 lines (70 loc) · 1.82 KB
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
82
83
84
85
.PHONY: build test clean run docker-build docker-run help
# Go related variables
BINARY_NAME=server
MAIN_PATH=./cmd/server
# Docker related variables
DOCKER_IMAGE=gitflow
DOCKER_TAG=latest
# Build the project
build:
@echo "Building..."
go build -o $(BINARY_NAME) $(MAIN_PATH)
# Run the project
run:
@echo "Running..."
go run $(MAIN_PATH)
# Clean build files
clean:
@echo "Cleaning..."
go clean
rm -f $(BINARY_NAME)
# Run tests
test:
@echo "Running tests..."
go test ./... -v
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out
# Format code
fmt:
@echo "Formatting code..."
go fmt ./...
# Vet code
vet:
@echo "Vetting code..."
go vet ./...
# Build docker image
docker-build:
@echo "Building docker image..."
docker build -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
# Run docker container
docker-run:
@echo "Running docker container..."
docker run -p 50051:50051 $(DOCKER_IMAGE):$(DOCKER_TAG)
# Stop all running containers
docker-stop:
@echo "Stopping all running containers..."
docker stop $$(docker ps -a -q)
# Install dependencies
deps:
@echo "Installing dependencies..."
go mod download
go mod tidy
# Show help
help:
@echo "Available commands:"
@echo " make build - Build the project"
@echo " make run - Run the project"
@echo " make clean - Clean build files"
@echo " make test - Run tests"
@echo " make test-coverage - Run tests with coverage"
@echo " make fmt - Format code"
@echo " make vet - Vet code"
@echo " make deps - Install dependencies"
@echo " make docker-build - Build docker image"
@echo " make docker-run - Run docker container"
@echo " make docker-stop - Stop all running containers"
# Default target
default: help