-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (50 loc) · 1.4 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
# Variables
DOCKER_IMAGE = iuriikogan/snyk-controller
DOCKER_TAG = latest
DOCKERFILE = Dockerfile
APP_NAME = snyk-controller
BUILD_DIR = ./build
# Commands
GO_CMD = go
DOCKER_CMD = docker
# Default target
.PHONY: all
all: build
# Build the Go application
.PHONY: build
build:
@echo "Building Go application..."
mkdir -p $(BUILD_DIR)
$(GO_CMD) build -o $(BUILD_DIR)/$(APP_NAME) ./main.go
# Build the Docker image
.PHONY: docker-build
docker-build: build
@echo "Building Docker image..."
$(DOCKER_CMD) build -t $(DOCKER_IMAGE):$(DOCKER_TAG) -f $(DOCKERFILE) .
# Run the application locally
.PHONY: run
run: build
@echo "Running application locally..."
./$(BUILD_DIR)/$(APP_NAME)
# Push the Docker image to the container registry
.PHONY: push
push: docker-build
@echo "Pushing Docker image to registry..."
$(DOCKER_CMD) push $(DOCKER_IMAGE):$(DOCKER_TAG)
# Clean the build artifacts
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
rm -rf $(BUILD_DIR)/$(APP_NAME)
# Print help
.PHONY: help
help:
@echo "Makefile for snyk-controller"
@echo ""
@echo "Usage:"
@echo " make build - Build the Go application"
@echo " make docker-build - Build the Docker image"
@echo " make run - Run the application locally"
@echo " make push - Push the Docker image to the registry"
@echo " make clean - Clean the build artifacts"
@echo " make help - Show this help message"