@@ -12,6 +12,7 @@ LICENSE_IGNORE := -e /testdata/
12
12
GO_TEST_FLAGS ?= -v -race -cover
13
13
14
14
IMAGE_PLATFORM = linux/amd64
15
+ BUILDX_ARGS =
15
16
GOPRIVATE =github.com/grafana/frostdb
16
17
17
18
# Boiler plate for building Docker containers.
@@ -21,10 +22,11 @@ IMAGE_PREFIX ?= us.gcr.io/kubernetes-dev/
21
22
IMAGE_TAG ?= $(shell ./tools/image-tag)
22
23
GIT_REVISION := $(shell git rev-parse --short HEAD)
23
24
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
25
+ GIT_LAST_COMMIT_DATE := $(shell git log -1 --date=raw --format=% cd | cut -d ' ' -f 1 | xargs -i date -d @{} -u +"% Y-% m-% dT% H:% M:% SZ")
24
26
25
27
# Build flags
26
28
VPREFIX := github.com/grafana/fire/pkg/util/build
27
- GO_LDFLAGS := -X $(VPREFIX ) .Branch=$(GIT_BRANCH ) -X $(VPREFIX ) .Version=$(IMAGE_TAG ) -X $(VPREFIX ) .Revision=$(GIT_REVISION ) -X $(VPREFIX ) .BuildUser= $( shell whoami) @ $( shell hostname) -X $( VPREFIX ) . BuildDate=$(shell date -u +" % Y- % m- % dT % H: % M: % SZ" )
29
+ GO_LDFLAGS := -X $(VPREFIX ) .Branch=$(GIT_BRANCH ) -X $(VPREFIX ) .Version=$(IMAGE_TAG ) -X $(VPREFIX ) .Revision=$(GIT_REVISION ) -X $(VPREFIX ) .BuildDate=$(GIT_LAST_COMMIT_DATE )
28
30
GO_FLAGS := -ldflags "-extldflags \"-static\" -s -w $(GO_LDFLAGS ) " -tags netgo -mod=mod
29
31
30
32
.PHONY : help
@@ -101,7 +103,7 @@ check/go/mod: go/mod
101
103
102
104
103
105
define docker_buildx
104
- docker buildx build $(1 ) --ssh default --platform $(IMAGE_PLATFORM ) --build-arg=revision=$(GIT_REVISION ) -t $(IMAGE_PREFIX )$(shell basename $(@D ) ) -t $(IMAGE_PREFIX )$(shell basename $(@D ) ) :$(IMAGE_TAG ) -f cmd/$(shell basename $(@D ) ) /Dockerfile .
106
+ docker buildx build $(1 ) --ssh default --platform $(IMAGE_PLATFORM ) $( BUILDX_ARGS ) --build-arg=revision=$(GIT_REVISION ) -t $(IMAGE_PREFIX )$(shell basename $(@D ) ) -t $(IMAGE_PREFIX )$(shell basename $(@D ) ) :$(IMAGE_TAG ) -f cmd/$(shell basename $(@D ) ) /Dockerfile .
105
107
endef
106
108
107
109
define deploy
@@ -121,6 +123,31 @@ docker-image/fire/build:
121
123
docker-image/fire/push :
122
124
$(call docker_buildx,--push)
123
125
126
+ define UPDATER_CONFIG_JSON
127
+ {
128
+ "repo_name": "deployment_tools",
129
+ "destination_branch": "master",
130
+ "wait_for_ci": true,
131
+ "wait_for_ci_branch_prefix": "automation/fire-dev-deploy",
132
+ "wait_for_ci_timeout": "10m",
133
+ "wait_for_ci_required_status": [
134
+ "continuous-integration/drone/push"
135
+ ],
136
+ "update_jsonnet_attribute_configs": [
137
+ {
138
+ "file_path": "ksonnet/environments/fire/dev-us-central-0.fire-dev-001/images.libsonnet",
139
+ "jsonnet_key": "fire",
140
+ "jsonnet_value": "$(IMAGE_PREFIX ) fire:$(IMAGE_TAG ) "
141
+ }
142
+ ]
143
+ }
144
+ endef
145
+
146
+ .PHONY : docker-image/fire/deploy-dev-001
147
+ docker-image/fire/deploy-dev-001 : export CONFIG_JSON:=$(call UPDATER_CONFIG_JSON)
148
+ docker-image/fire/deploy-dev-001 : $(BIN ) /updater
149
+ $(BIN ) /updater
150
+
124
151
.PHONY : clean
125
152
clean : # # Delete intermediate build artifacts
126
153
@# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs
@@ -174,6 +201,10 @@ $(BIN)/mage: Makefile go.mod
174
201
@mkdir -p $(@D )
175
202
GOBIN=$(abspath $(@D ) ) $(GO ) install github.com/magefile/mage@v1.13.0
176
203
204
+ $(BIN ) /updater : Makefile
205
+ @mkdir -p $(@D )
206
+ GOBIN=$(abspath $(@D ) ) GOPRIVATE=github.com/grafana/deployment_tools $(GO ) install github.com/grafana/deployment_tools/drone/plugins/cmd/updater@d64d509
207
+
177
208
KIND_CLUSTER = fire-dev
178
209
179
210
.PHONY : helm/lint
0 commit comments