-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
107 lines (83 loc) · 2.85 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
ENVIRONMENT ?= dev
CONTAINER_REPO ?= radix$(ENVIRONMENT)
DOCKER_REGISTRY ?= $(CONTAINER_REPO).azurecr.io
BINS = radix-api
IMAGES = radix-api
GIT_TAG = $(shell git describe --tags --always 2>/dev/null)
CURRENT_FOLDER = $(shell pwd)
VERSION ?= ${GIT_TAG}
IMAGE_TAG ?= ${VERSION}
LDFLAGS += -s -w
CX_OSES = linux windows
CX_ARCHS = amd64
.PHONY: build
build: $(BINS)
.PHONY: test
test:
go test -cover `go list ./...`
build-kaniko:
docker run --rm -it -v $(CURRENT_FOLDER):/workspace gcr.io/kaniko-project/executor:v0.7.0 --destination=$(DOCKER_REGISTRY)/radix-api-server:3hv6o --snapshotMode=time --cache=true
# This make command is only needed for local testing now
# we also do make swagger inside Dockerfile
.PHONY: swagger
swagger:
rm -f ./swaggerui_src/swagger.json ./swaggerui/statik.go
swagger generate spec -o ./swagger.json --scan-models
mv swagger.json ./swaggerui_src/swagger.json
statik -src=./swaggerui_src/ -p swaggerui
deploy-api:
draft up
.PHONY: deploy
deploy:
# Add and update ACR Helm repo
az acr helm repo add --name $(CONTAINER_REPO) && helm repo update
# Download deploy key and other secrets
az keyvault secret download -f radix-api-radixregistration-values.yaml -n radix-api-radixregistration-values --vault-name radix-boot-dev-vault
# Install RR
helm upgrade --install radix-api -f radix-api-radixregistration-values.yaml $(CONTAINER_REPO)/radix-registration
# Delete secret file to avvoid being checked in
rm radix-api-radixregistration-values.yaml
# Allow operator to pick up RR. TODO should be handled with waiting for app namespace
sleep 5
# Create pipeline
helm upgrade --install radix-pipeline-api $(CONTAINER_REPO)/radix-pipeline-invocation --set name="radix-api" --set cloneURL="git@github.com:Statoil/radix-api.git" --set cloneBranch="master"
.PHONY: undeploy
undeploy:
helm delete --purge radix-pipeline-api
helm delete --purge radix-api
.PHONY: $(BINS)
$(BINS): vendor
go build -ldflags '$(LDFLAGS)' -o bin/$@ .
.PHONY: docker-build
docker-build: $(addsuffix -image,$(IMAGES))
%-image:
docker build $(DOCKER_BUILD_FLAGS) -t $(DOCKER_REGISTRY)/$*:$(IMAGE_TAG) .
.PHONY: docker-push
docker-push: $(addsuffix -push,$(IMAGES))
%-push:
docker push $(DOCKER_REGISTRY)/$*:$(IMAGE_TAG)
HAS_GOMETALINTER := $(shell command -v gometalinter;)
HAS_DEP := $(shell command -v dep;)
HAS_GIT := $(shell command -v git;)
HAS_SWAGGER := $(shell command -v swagger;)
HAS_STATIK := $(shell command -v statik;)
vendor:
ifndef HAS_GIT
$(error You must install git)
endif
ifndef HAS_DEP
go get -u github.com/golang/dep/cmd/dep
endif
ifndef HAS_GOMETALINTER
go get -u github.com/alecthomas/gometalinter
gometalinter --install
endif
dep ensure
ifndef HAS_SWAGGER
go get -u github.com/go-swagger/go-swagger/cmd/swagger
endif
ifndef HAS_STATIK
go get github.com/rakyll/statik
endif
.PHONY: bootstrap
bootstrap: vendor