-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (47 loc) · 1.62 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
# Variables
APP_NAME := webcrawler
SRC_DIR := ./cmd/$(APP_NAME)
CLIENT_DIR := ./cmd/$(APP_NAME)-client
BUILD_DIR := ./bin
VERSION := 1.0
# Targets
.PHONY: all build run test clean
# Default target: build, test, and run the application
all: build test run
# Build the application and put the binary in the bin directory
build:
@echo "Building $(APP_NAME)..."
@mkdir -p $(BUILD_DIR)
@go build -o $(BUILD_DIR)/$(APP_NAME) $(SRC_DIR)
# Run the application
run: build
@echo "Running $(APP_NAME)..."
@$(BUILD_DIR)/$(APP_NAME)
# Build the client and put the binary in the bin directory
build-client:
@echo "Building $(APP_NAME)-client..."
@mkdir -p $(BUILD_DIR)
@go build -o $(BUILD_DIR)/$(APP_NAME)-client $(CLIENT_DIR)
run-client: build-client
@echo "Running $(APP_NAME)-client..."
@$(BUILD_DIR)/$(APP_NAME)-client
docker-webcrawler:
docker build -f docker/webcrawler/Dockerfile -t webcrawler:$(VERSION) .
docker-webcrawler-run: docker-webcrawler
docker run -p 8081:8081 webcrawler:$(VERSION)
docker-webcrawler-push: docker-webcrawler
docker tag webcrawler:$(VERSION) ghcr.io/karan56625/webcrawler:$(VERSION)
docker push ghcr.io/karan56625/webcrawler:$(VERSION)
docker-webcrawler-client:
docker build -f docker/webcrawler-client/Dockerfile -t webcrawler-client:$(VERSION) .
docker-webcrawler-client-push: docker-webcrawler-client
docker tag webcrawler-client:$(VERSION) ghcr.io/karan56625/webcrawler-client:$(VERSION)
docker push ghcr.io/karan56625/webcrawler-client:$(VERSION)
#Run all unit tests
test:
@echo "Running tests..."
@go test ./...
# Clean up the build directory
clean:
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)