forked from napptive/example-app-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (56 loc) · 1.89 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
#Version must be overrided in the CI
VERSION=$(shell cat version)
# Docker options
TARGET_DOCKER_REGISTRY ?= $$USER
# Variables
BUILD_FOLDER=$(CURDIR)/build
BIN_FOLDER=$(BUILD_FOLDER)/bin
DOCKER_FOLDER=$(BUILD_FOLDER)/docker
K8S_FOLDER=$(BUILD_FOLDER)/k8s
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
SED := gsed
else
SED := sed
endif
#Docker command
DOCKERCMD?=docker
# Tools
NPM_CMD=npm
NPM_BUILD=$(NPM_CMD) build
NPM_TEST=$(NPM_CMD) test
.PHONY: clean
# Remove build files
clean:
@echo "Cleaining build folder: $(BUILD_FOLDER)"
@rm -rf $(BUILD_FOLDER)
.PHONY: test
test:
@echo "Executing tests"
@$(NPM_TEST)
.PHONY: docker-build
docker-build: docker-build-api docker-build-at
.PHONY: docker-build-api
docker-build-api:
$(DOCKERCMD) build --platform linux/amd64 -t $(TARGET_DOCKER_REGISTRY)/example-app-nodejs-api:$(VERSION) .
.PHONY: docker-build-at
docker-build-at:
$(DOCKERCMD) build -f Dockerfile.newman --platform linux/amd64 -t $(TARGET_DOCKER_REGISTRY)/example-app-nodejs-api-at-runner:$(VERSION) .
.PHONY: docker-push
docker-push: docker-build
@echo Pushing example-app-nodejs Docker images to DockerHub
$(DOCKERCMD) push $(TARGET_DOCKER_REGISTRY)/example-app-nodejs-api:$(VERSION) || exit 1;
$(DOCKERCMD) push $(TARGET_DOCKER_REGISTRY)/example-app-nodejs-api-at-runner:$(VERSION) || exit 1;
.PHONY: k8s
k8s:
@rm -r $(K8S_FOLDER) || true
@mkdir -p $(K8S_FOLDER)
@mkdir -p $(K8S_FOLDER)/todoapp
@mkdir -p $(K8S_FOLDER)/todoat
@cp deployments/todoapp/* $(K8S_FOLDER)/todoapp/.
@cp deployments/todoat/* $(K8S_FOLDER)/todoat/.
@$(SED) -i 's/TARGET_DOCKER_REGISTRY/'$(TARGET_DOCKER_REGISTRY)'/' $(K8S_FOLDER)/todoapp/*.yaml
@$(SED) -i 's/TARGET_DOCKER_REGISTRY/'$(TARGET_DOCKER_REGISTRY)'/' $(K8S_FOLDER)/todoat/*.yaml
@$(SED) -i 's/VERSION/$(VERSION)/' $(K8S_FOLDER)/todoapp/*.yaml
@$(SED) -i 's/VERSION/$(VERSION)/' $(K8S_FOLDER)/todoat/*.yaml
@echo "Kubernetes files ready at $(K8S_FOLDER)/"