This repository has been archived by the owner on Jan 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Makefile
156 lines (126 loc) · 5.3 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
################################################################################
# Version details #
################################################################################
GIT_VERSION = $(shell git describe --always --abbrev=7 --dirty --match=NeVeRmAtCh)
ifdef REL_VERSION
OSIRIS_VERSION := $(REL_VERSION)
else
OSIRIS_VERSION := devel
endif
################################################################################
# Go build details #
################################################################################
BASE_PACKAGE_NAME := github.com/deislabs/osiris
LDFLAGS = -w -X $(BASE_PACKAGE_NAME)/pkg/version.commit=$(GIT_VERSION) \
-X $(BASE_PACKAGE_NAME)/pkg/version.version=$(OSIRIS_VERSION)
################################################################################
# Containerized development environment-- or lack thereof #
################################################################################
ifneq ($(SKIP_DOCKER),true)
PROJECT_ROOT := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
DEV_IMAGE := quay.io/deis/lightweight-docker-go:v0.5.0
DOCKER_CMD := docker run \
-it \
--rm \
-e SKIP_DOCKER=true \
-v $(PROJECT_ROOT):/go/src/$(BASE_PACKAGE_NAME) \
-w /go/src/$(BASE_PACKAGE_NAME) $(DEV_IMAGE)
HELM_IMAGE := quay.io/deis/acr-publishing-tools:v0.2.0
DOCKER_HELM_CMD := docker run \
--rm \
-v $(PROJECT_ROOT):/go/src/$(BASE_PACKAGE_NAME) \
-w /go/src/$(BASE_PACKAGE_NAME) \
$(HELM_IMAGE)
endif
################################################################################
# Docker images we build and publish #
################################################################################
ifdef DOCKER_REGISTRY
DOCKER_REGISTRY := $(DOCKER_REGISTRY)/
endif
ifdef DOCKER_REGISTRY_NAMESPACE
DOCKER_REGISTRY_NAMESPACE := $(DOCKER_REGISTRY_NAMESPACE)/
endif
BASE_IMAGE_NAME := osiris
RC_IMAGE_NAME := $(DOCKER_REGISTRY)$(DOCKER_REGISTRY_NAMESPACE)$(BASE_IMAGE_NAME):$(GIT_VERSION)
RC_MUTABLE_IMAGE_NAME := $(DOCKER_REGISTRY)$(DOCKER_REGISTRY_NAMESPACE)$(BASE_IMAGE_NAME):edge
REL_IMAGE_NAME := $(DOCKER_REGISTRY)$(DOCKER_REGISTRY_NAMESPACE)$(BASE_IMAGE_NAME):$(REL_VERSION)
REL_MUTABLE_IMAGE_NAME := $(DOCKER_REGISTRY)$(DOCKER_REGISTRY_NAMESPACE)$(BASE_IMAGE_NAME):latest
################################################################################
# Utility targets #
################################################################################
# Allow developers to step into the containerized development environment--
# unconditionally requires docker
.PHONY: dev
dev:
$(DOCKER_CMD) bash
# Install/update dependencies
.PHONY: dep
dep:
$(DOCKER_CMD) dep ensure -v
################################################################################
# Tests #
################################################################################
# Verifies there are no disrepancies between desired dependencies and the
# tracked, vendored dependencies
.PHONY: verify-vendored-code
verify-vendored-code:
$(DOCKER_CMD) scripts/verify-vendored-code.sh
# Executes unit tests
.PHONY: test-unit
test-unit:
$(DOCKER_CMD) scripts/test-unit.sh
# Executes an extensive series of lint checks against code
.PHONY: lint
lint:
$(DOCKER_CMD) scripts/lint.sh
################################################################################
# Build / Publish #
################################################################################
# Build the Osiris binaries and Docker image
.PHONY: build
build:
docker build \
--build-arg BASE_PACKAGE_NAME='$(BASE_PACKAGE_NAME)' \
--build-arg LDFLAGS='$(LDFLAGS)' \
-t $(RC_IMAGE_NAME) \
.
docker tag $(RC_IMAGE_NAME) $(RC_MUTABLE_IMAGE_NAME)
# Push release candidate image
.PHONY: push-rc
push-rc: build
docker push $(RC_IMAGE_NAME)
docker push $(RC_MUTABLE_IMAGE_NAME)
# Rebuild and push officially released, semantically versioned images with
# semantically versioned binary
.PHONY: push-release
push-release:
ifndef REL_VERSION
$(error REL_VERSION is undefined)
endif
@# This pull is a verification that this commit has successfully cleared the
@# master pipeline.
docker pull $(RC_IMAGE_NAME)
docker build \
--build-arg BASE_PACKAGE_NAME='$(BASE_PACKAGE_NAME)' \
--build-arg LDFLAGS='$(LDFLAGS)' \
-t $(REL_IMAGE_NAME) \
.
docker tag $(REL_IMAGE_NAME) $(REL_MUTABLE_IMAGE_NAME)
docker push $(REL_IMAGE_NAME)
docker push $(REL_MUTABLE_IMAGE_NAME)
################################################################################
# Chart-Related Targets #
################################################################################
.PHONY: lint-chart
lint-chart:
$(DOCKER_HELM_CMD) scripts/lint-chart.sh
.PHONY: publish-rc-chart
publish-rc-chart:
$(DOCKER_HELM_CMD) scripts/publish-rc-chart.sh $(GIT_VERSION)
.PHONY: publish-release-chart
publish-release-chart:
ifndef REL_VERSION
$(error REL_VERSION is undefined)
endif
$(DOCKER_HELM_CMD) scripts/publish-release-chart.sh $(REL_VERSION)