-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (40 loc) · 1.75 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
DOCKER_IMAGE ?= -docs
DOCKER_REGISTRY ?= quay.io
DOCKER_REPO ?= $(DOCKER_REGISTRY)/ukhomeofficedigital/$(DOCKER_IMAGE)
KUBE_CONTEXT ?= -dev
KUBE_DEPLOYMENT ?= -docs
KUBE_CONTAINER ?= app
kubectl ?= kubectl --context $(KUBE_CONTEXT)
patch_version != jq -r '.version' 'package.json'
minor_version != echo "$(patch_version)" | awk -F '.' '{print $$1"."$$2}'
major_version != echo "$(patch_version)" | awk -F '.' '{print $$1}'
full_version != echo "$(patch_version)-$${BUILD_NUMBER/%/-}$$(git rev-parse --short HEAD)"
.PHONY: all build clean deploy deps distclean docker docker-clean docker-push node-deps test unit-test
all: deps test docker
clean:
npm run clean
rm -rf node_modules/
distclean: clean docker-clean
deps: node-deps
node-deps: node_modules/.bin/webpack
node_modules/%: package.json
pnpm install
build: dist/server/index.js
dist/%: node_modules/.bin/webpack
npm run build
docker: build
docker build -t '$(DOCKER_IMAGE)' .
docker-clean:
docker rmi -f '$(DOCKER_IMAGE)' || true
docker-push: docker
docker tag $(DOCKER_IMAGE) '$(DOCKER_REPO):$(full_version)' && docker push '$(DOCKER_REPO):$(full_version)'
docker tag $(DOCKER_IMAGE) '$(DOCKER_REPO):$(patch_version)' && docker push '$(DOCKER_REPO):$(patch_version)'
docker tag $(DOCKER_IMAGE) '$(DOCKER_REPO):$(minor_version)' && docker push '$(DOCKER_REPO):$(minor_version)'
docker tag $(DOCKER_IMAGE) '$(DOCKER_REPO):$(major_version)' && docker push '$(DOCKER_REPO):$(major_version)'
docker tag $(DOCKER_IMAGE) '$(DOCKER_REPO):latest' && docker push '$(DOCKER_REPO):latest'
deploy: docker-push
$(kubectl) set image "deployment/$(KUBE_DEPLOYMENT)" "$(KUBE_CONTAINER)=$(DOCKER_REPO):$(full_version)"
$(kubectl) rollout status "deployment/$(KUBE_DEPLOYMENT)"
unit-test: node-deps
npm test
test: unit-test