Skip to content

Commit a901941

Browse files
Added makefile to run application (#9)
* first version of makefile * updated the makefile and added the banner for it
1 parent 9728304 commit a901941

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

Makefile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
APP_NAME = k8s-custom-controller
2+
DOCKER_USER = manzilrahul
3+
VERSION ?= 1.0.1
4+
IMAGE_NAME = $(DOCKER_USER)/$(APP_NAME)
5+
6+
# 🖼️ Logo banner
7+
define ascii_banner
8+
@cat banner.txt
9+
endef
10+
11+
print-vars:
12+
$(call ascii_banner)
13+
@echo "🔧 APP_NAME = $(APP_NAME)"
14+
@echo "👤 DOCKER_USER = $(DOCKER_USER)"
15+
@echo "🏷️ VERSION = $(VERSION)"
16+
@echo "📦 IMAGE_NAME = $(IMAGE_NAME)"
17+
18+
run:
19+
$(call ascii_banner)
20+
@echo "▶️ Running Go app locally..."
21+
go run main.go
22+
23+
build:
24+
$(call ascii_banner)
25+
@echo "🛠️ Building Go binary..."
26+
go build -o $(APP_NAME)
27+
28+
fmt:
29+
$(call ascii_banner)
30+
@echo "🧹 Formatting Go code..."
31+
go fmt ./...
32+
33+
up:
34+
$(call ascii_banner)
35+
@echo "📦 Starting Docker Compose..."
36+
docker-compose up --build
37+
38+
down:
39+
$(call ascii_banner)
40+
@echo "🛑 Stopping Docker Compose..."
41+
docker-compose down
42+
43+
build-image:
44+
$(call ascii_banner)
45+
@echo "🐳 Building Docker image $(IMAGE_NAME):$(VERSION) and :latest..."
46+
docker build -t $(IMAGE_NAME):$(VERSION) -t $(IMAGE_NAME):latest .
47+
48+
push-image:
49+
$(call ascii_banner)
50+
@echo "📤 Pushing Docker image..."
51+
docker push $(IMAGE_NAME):$(VERSION)
52+
docker push $(IMAGE_NAME):latest

banner.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
__ ____ ______ __ __ __
3+
/ /__ ( __ ) _____ / ____/____ ____ / /_ _____ ____ / // /___ _____
4+
/ //_// __ |/ ___/ / / / __ \ / __ \ / __// ___// __ \ / // // _ \ / ___/
5+
/ ,< / /_/ /(__ ) / /___ / /_/ // / / // /_ / / / /_/ // // // __// /
6+
/_/|_| \____//____/ \____/ \____//_/ /_/ \__//_/ \____//_//_/ \___//_/
7+
8+

guide.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,16 @@ docker run --rm --name k8s-custom-controller \
77
```
88
```go
99
kubectl create deployment my-deployment --image=nginx:latest --labels=app=nginx,env=prod
10+
```
11+
```go
12+
// https://patorjk.com/software/taag/#p=display&h=1&v=0&f=Slant&t=k8s%20Controller%0A
13+
// for creating the ASCII Banner
14+
make build-image # builds 1.0.1 and latest
15+
make push-image # pushes 1.0.1 and latest
16+
17+
# Override version if needed:
18+
make build-image VERSION=1.0.2
19+
make push-image VERSION=1.0.2
20+
21+
make build-image APP_NAME=custom-controller DOCKER_USER=yourusername VERSION=2.0.0
1022
```

0 commit comments

Comments
 (0)