-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (53 loc) · 1.17 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
# Variables
GO = go
GOFMT = gofmt
GOFILES = $(shell find . -name '*.go')
APP_NAME = meeting-service
DOCKER_IMAGE_NAME = meeting-service-image
DOCKER_CONTAINER_NAME = meeting-service-container
# Default target
.PHONY: all
all: build
# Build the Go application
.PHONY: build
build:
$(GO) build -o $(APP_NAME) ./cmd/meeting-service/main.go
# Run the Go application directly
.PHONY: run
run:
$(GO) run ./cmd/meeting-service/main.go
# Format Go code
.PHONY: fmt
fmt:
$(GOFMT) -s -w $(GOFILES)
# Test Go application
.PHONY: test
test:
$(GO) test ./...
# Build Docker image
.PHONY: docker-build
docker-build:
docker build -t $(DOCKER_IMAGE_NAME) .
# Run Docker container
.PHONY: docker-run
docker-run:
docker-compose up -d
# Stop Docker container
.PHONY: docker-stop
docker-stop:
docker-compose down
# Clean Go build artifacts
.PHONY: clean
clean:
rm -f $(APP_NAME)
# Rebuild the Docker image and run the container
.PHONY: docker-restart
docker-restart: docker-stop docker-build docker-run
# Show Docker logs
.PHONY: docker-logs
docker-logs:
docker logs -f $(DOCKER_CONTAINER_NAME)
# Clean up Go build and Docker images
.PHONY: clean-all
clean-all: clean
docker rmi $(DOCKER_IMAGE_NAME)