-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (63 loc) · 2.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Define variables
IMAGE_NAME := solar-system
CONTAINER_NAME := solar-system
PORT := 3000
# Build Docker image
build:
docker build -t $(IMAGE_NAME) .
# Run Docker container in detached mode
run:
docker run -d -p $(PORT):$(PORT) --name $(CONTAINER_NAME) $(IMAGE_NAME)
# Stop Docker container
stop:
docker stop $(CONTAINER_NAME)
# Remove Docker container
remove:
docker rm $(CONTAINER_NAME)
# Remove Docker image
remove-image:
docker rmi $(IMAGE_NAME)
# View running containers
ps:
docker ps
# View all containers (including stopped ones)
ps-all:
docker ps -a
# View Docker images
images:
docker images
# Execute a command inside the running container (e.g., bash shell)
exec:
docker exec -it $(CONTAINER_NAME) bash
# Create Kubernetes cluster with 2 worker and one control plane
create-cluster:
kind create cluster --config cluster-config.yml
# Delete the Kubernetes cluster
delete-cluster:
kind delete cluster --name kind
# Make service accessible
port-forward:
kubectl port-forward service/solar-system 3000:3000
# Clean up (stop and remove) all containers and images
clean:
docker stop $(shell docker ps -aq) || true
docker rm $(shell docker ps -aq) || true
docker rmi $(shell docker images -aq) || true
# Help target to display available targets and their descriptions
help:
@echo "Available targets:"
@echo " build Build Docker image"
@echo " run Run Docker container in detached mode"
@echo " stop Stop Docker container"
@echo " remove Remove Docker container"
@echo " remove-image Remove Docker image"
@echo " ps View running containers"
@echo " ps-all View all containers (including stopped ones)"
@echo " images View Docker images"
@echo " exec Execute a command inside the running container"
@echo " clean Clean up (stop and remove) all containers and images"
@echo " help Display this help message"
@echo " create-cluster Create Kubernetes cluster with 2 worker and one control plane"
@echo " delete-cluster Delete the Kubernetes cluster"
# Make the 'build' target the default target when 'make' is run without arguments
.DEFAULT_GOAL := build