-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (45 loc) · 1.15 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
#Compile and run the binary
binaryName ?= GoBookstoreAPI
$(binaryName):
go build -o ./$(binaryName)
build: $(binaryName)
port ?= 3000
run: build
./$(binaryName) serve --port=$(port)
clean::
-rm GoBookstoreAPI
#Run with helm
helmDeploymentName ?= bookstorehelm
helmInstall:
helm install $(helmDeploymentName) deploy/helm
-kubectl get nodes -o wide
clean::
-helm uninstall $(helmDeploymentName)
#Run with docker
imageName ?= sami7786/gobookstoreapi
tag ?= latest
dockerImage:
ifeq ($(shell docker images $(imageName):$(tag) -a -q),)
docker build -t $(imageName):$(tag) .
else
@echo "image already exists"
endif
dockerRun: dockerImage
docker run -d -p $(port):$(port) --name=$(binaryName) $(imageName):$(tag)
@docker logs $(binaryName)
DOCKER_USER ?= sami7786
dockerLogin:
@docker login -u $(DOCKER_USER) -p $(DOCKER_PASS)
dockerPush: dockerImage dockerLogin
docker push $(imageName):$(tag)
#Push changes to remote repository
commitMessage ?= "from makefile"
gitPush:
git add .
git commit -m $(commitMessage)
git push
clean::
-docker kill $(binaryName)
-docker rm $(binaryName)
cleanAll:: clean
docker rmi -f $$(docker images $(imageName):$(tag) -a -q)