@@ -6,32 +6,26 @@ DOCKERHUB_USER=weaveworks
6
6
SCOPE_EXE =prog/scope
7
7
SCOPE_EXPORT =scope.tar
8
8
CLOUD_AGENT_EXPORT =cloud-agent.tar
9
- SCOPE_UI_BUILD_IMAGE =$(DOCKERHUB_USER ) /scope-ui-build
10
- SCOPE_UI_BUILD_UPTODATE =.scope_ui_build.uptodate
9
+ SCOPE_UI_BUILD_IMAGE =node:10.19
11
10
SCOPE_BACKEND_BUILD_IMAGE =$(DOCKERHUB_USER ) /scope-backend-build
12
11
SCOPE_BACKEND_BUILD_UPTODATE =.scope_backend_build.uptodate
13
12
SCOPE_VERSION =$(shell git rev-parse --short HEAD)
14
13
GIT_REVISION =$(shell git rev-parse HEAD)
15
- WEAVENET_VERSION =2.1.3
14
+ WEAVENET_VERSION =2.8.1
16
15
RUNSVINIT =vendor/github.com/peterbourgon/runsvinit/runsvinit
17
16
CODECGEN_DIR =vendor/github.com/ugorji/go/codec/codecgen
18
- CODECGEN_EXE =$(CODECGEN_DIR ) /bin/codecgen_$(shell go env GOHOSTOS) _$(shell go env GOHOSTARCH)
19
17
CODECGEN_UID =0
20
18
GET_CODECGEN_DEPS =$(shell find $(1 ) -maxdepth 1 -type f -name '* .go' -not -name '* _test.go' -not -name '* .codecgen.go' -not -name '* .generated.go')
21
19
CODECGEN_TARGETS =report/report.codecgen.go render/detailed/detailed.codecgen.go
22
20
RM =--rm
23
21
RUN_FLAGS =-ti
24
22
BUILD_IN_CONTAINER =true
25
23
GO_ENV=GOGC =off
26
- GO_BUILD_TAGS ='netgo unsafe'
24
+ GO_BUILD_TAGS ='netgo osusergo unsafe'
27
25
GO_BUILD_FLAGS =-mod vendor -ldflags "-extldflags \"-static\" -X main.version=$(SCOPE_VERSION ) -s -w" -tags $(GO_BUILD_TAGS )
28
- GOOS =$(shell go tool dist env | grep GOOS | sed -e 's/GOOS="\(.* \) "/\1/')
29
-
30
- ifeq ($(GOOS ) ,linux)
31
- GO_ENV+=CGO_ENABLED =1
32
- endif
33
26
34
27
ifeq ($(GOARCH ) ,arm)
28
+ GO_ENV+=CGO_ENABLED =1
35
29
ARM_CC=CC =/usr/bin/arm-linux-gnueabihf-gcc
36
30
endif
37
31
@@ -72,7 +66,7 @@ docker/%: %
72
66
73
67
$(CLOUD_AGENT_EXPORT ) : docker/Dockerfile.cloud-agent docker/$(SCOPE_EXE ) docker/weave docker/weaveutil
74
68
75
- $(SCOPE_EXPORT ) : docker/Dockerfile.scope $(CLOUD_AGENT_EXPORT ) docker/$(RUNSVINIT ) docker/demo.json docker/ run-app docker/run-probe docker/entrypoint.sh
69
+ $(SCOPE_EXPORT ) : docker/Dockerfile.scope $(CLOUD_AGENT_EXPORT ) docker/$(RUNSVINIT ) docker/run-app docker/run-probe docker/entrypoint.sh
76
70
77
71
$(RUNSVINIT ) : vendor/github.com/peterbourgon/runsvinit/* .go
78
72
@@ -89,9 +83,12 @@ ifeq ($(BUILD_IN_CONTAINER),true)
89
83
$(SCOPE_EXE ) $(RUNSVINIT ) lint tests shell prog/staticui/staticui.go prog/externalui/externalui.go : $(SCOPE_BACKEND_BUILD_UPTODATE )
90
84
@mkdir -p $(shell pwd) /.pkg
91
85
$(SUDO ) docker run $(RM ) $(RUN_FLAGS ) \
92
- -v $(shell pwd) :/go/src/github.com/weaveworks/scope \
93
- -v $(shell pwd) /.pkg:/go/pkg \
86
+ -v $(shell pwd) :/go/src/github.com/weaveworks/scope:delegated,z \
87
+ -v $(shell pwd) /.pkg:/go/pkg:delegated,z \
88
+ -v $(shell pwd) /.cache:/go/cache:delegated,z \
89
+ -u $(shell id -u ${USER}) :$(shell id -g ${USER}) \
94
90
--net=host \
91
+ -e HOME=/go/src/github.com/weaveworks/scope \
95
92
-e GOARCH -e GOOS -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL \
96
93
-e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW -e TESTDIRS \
97
94
$(SCOPE_BACKEND_BUILD_IMAGE ) SCOPE_VERSION=$(SCOPE_VERSION ) CODECGEN_UID=$(CODECGEN_UID ) $@
101
98
$(SCOPE_EXE ) :
102
99
time $(GO ) build $(GO_BUILD_FLAGS ) -o $@ ./$(@D )
103
100
101
+ CODECGEN_EXE =$(CODECGEN_DIR ) /bin/codecgen_$(shell go env GOHOSTOS) _$(shell go env GOHOSTARCH)
102
+
104
103
% .codecgen.go : $(CODECGEN_EXE )
105
104
rm -f $@ ; $(GO_HOST ) build $(GO_BUILD_FLAGS ) ./$(@D ) # workaround for https://github.com/ugorji/go/issues/145
106
105
cd $(@D ) && $(WITH_GO_HOST_ENV ) GO111MODULE=off $(shell pwd) /$(CODECGEN_EXE ) -d $(CODECGEN_UID ) -rt $(GO_BUILD_TAGS ) -u -o $(@F ) $(notdir $(call GET_CODECGEN_DEPS,$(@D ) ) )
@@ -118,98 +117,66 @@ shell:
118
117
tests : $(CODECGEN_TARGETS ) prog/staticui/staticui.go prog/externalui/externalui.go
119
118
./tools/test -no-go-get -tags $(GO_BUILD_TAGS )
120
119
121
- lint :
120
+ lint : prog/staticui/staticui.go prog/externalui/externalui.go
122
121
./tools/lint
123
122
124
123
prog/staticui/staticui.go :
125
124
mkdir -p prog/staticui
126
- esc -o $@ -pkg staticui -prefix client/build client/build
125
+ $( NO_CROSS_COMP ) ; go run -mod vendor github.com/mjibson/ esc -o $@ -pkg staticui -prefix client/build client/build
127
126
128
127
prog/externalui/externalui.go :
129
128
mkdir -p prog/externalui
130
- esc -o $@ -pkg externalui -prefix client/build-external -include ' \.html$$' client/build-external
129
+ $( NO_CROSS_COMP ) ; go run -mod vendor github.com/mjibson/ esc -o $@ -pkg externalui -prefix client/build-external -include ' \.html$$' client/build-external
131
130
132
131
endif
133
132
134
133
ifeq ($(BUILD_IN_CONTAINER ) ,true)
135
134
136
135
SCOPE_UI_TOOLCHAIN =.cache/build_node_modules
137
136
SCOPE_UI_TOOLCHAIN_UPTODATE =$(SCOPE_UI_TOOLCHAIN ) /.uptodate
137
+ SCOPE_UI_BUILD_CMD =$(SUDO ) docker run $(RM ) $(RUN_FLAGS ) \
138
+ -v $(shell pwd) /.cache:/home/weave/scope/.cache:delegated,z \
139
+ -v $(shell pwd) /client:/home/weave/scope/client:delegated,z \
140
+ -v $(shell pwd) /$(SCOPE_UI_TOOLCHAIN ) :/home/weave/scope/client/node_modules:delegated,z \
141
+ -w /home/weave/scope/client \
142
+ -e HOME=/home/weave/scope/client \
143
+ -e NPM_CONFIG_LOGLEVEL=warn \
144
+ -e NPM_CONFIG_PROGRESS=false \
145
+ -e XDG_CACHE_HOME=/home/weave/scope/.cache \
146
+ -u $(shell id -u ${USER}) :$(shell id -g ${USER})
138
147
139
148
$(SCOPE_UI_TOOLCHAIN_UPTODATE ) : client/yarn.lock $(SCOPE_UI_BUILD_UPTODATE )
140
149
mkdir -p $(SCOPE_UI_TOOLCHAIN ) client/node_modules
141
150
if test " true" ! = " $( SCOPE_SKIP_UI_ASSETS) " ; then \
142
- $(SUDO ) docker run $(RM ) $(RUN_FLAGS ) \
143
- -v $(shell pwd) /.cache:/home/weave/scope/.cache \
144
- -v $(shell pwd) /client:/home/weave/scope/client \
145
- -v $(shell pwd) /$(SCOPE_UI_TOOLCHAIN ) :/home/weave/scope/client/node_modules \
146
- -w /home/weave/scope/client \
147
- -u $(shell id -u ${USER}) :$(shell id -g ${USER}) \
148
- $(SCOPE_UI_BUILD_IMAGE ) yarn install; \
151
+ $(SCOPE_UI_BUILD_CMD ) $(SCOPE_UI_BUILD_IMAGE ) yarn install; \
149
152
fi
150
153
touch $(SCOPE_UI_TOOLCHAIN_UPTODATE )
151
154
152
155
client/build/index.html : $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE )
153
156
mkdir -p client/build
154
157
if test " true" ! = " $( SCOPE_SKIP_UI_ASSETS) " ; then \
155
- $(SUDO ) docker run $(RM ) $(RUN_FLAGS ) \
156
- -v $(shell pwd) /.cache:/home/weave/scope/.cache \
157
- -v $(shell pwd) /client:/home/weave/scope/client \
158
- -v $(shell pwd) /$(SCOPE_UI_TOOLCHAIN ) :/home/weave/scope/client/node_modules \
159
- -w /home/weave/scope/client \
160
- -u $(shell id -u ${USER}) :$(shell id -g ${USER}) \
161
- $(SCOPE_UI_BUILD_IMAGE ) yarn run build; \
158
+ $(SCOPE_UI_BUILD_CMD ) $(SCOPE_UI_BUILD_IMAGE ) yarn run build; \
162
159
fi
163
160
164
161
client/build-external/index.html : $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE )
165
162
mkdir -p client/build-external
166
163
if test " true" ! = " $( SCOPE_SKIP_UI_ASSETS) " ; then \
167
- $(SUDO ) docker run $(RM ) $(RUN_FLAGS ) \
168
- -v $(shell pwd) /.cache:/home/weave/scope/.cache \
169
- -v $(shell pwd) /client:/home/weave/scope/client \
170
- -v $(shell pwd) /$(SCOPE_UI_TOOLCHAIN ) :/home/weave/scope/client/node_modules \
171
- -w /home/weave/scope/client \
172
- -u $(shell id -u ${USER}) :$(shell id -g ${USER}) \
173
- $(SCOPE_UI_BUILD_IMAGE ) yarn run build-external; \
164
+ $(SCOPE_UI_BUILD_CMD ) $(SCOPE_UI_BUILD_IMAGE ) yarn run build-external; \
174
165
fi
175
166
176
167
client-test : $(shell find client/app/scripts -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE )
177
- $(SUDO ) docker run $(RM ) $(RUN_FLAGS ) \
178
- -v $(shell pwd) /.cache:/home/weave/scope/.cache \
179
- -v $(shell pwd) /client:/home/weave/scope/client \
180
- -v $(shell pwd) /$(SCOPE_UI_TOOLCHAIN ) :/home/weave/scope/client/node_modules \
181
- -w /home/weave/scope/client \
182
- -u $(id -u ${USER} ) :$(id -g ${USER} ) \
183
- $(SCOPE_UI_BUILD_IMAGE ) yarn test
168
+ $(SCOPE_UI_BUILD_CMD ) $(SCOPE_UI_BUILD_IMAGE ) yarn test
184
169
185
170
client-lint : $(SCOPE_UI_TOOLCHAIN_UPTODATE )
186
- $(SUDO ) docker run $(RM ) $(RUN_FLAGS ) \
187
- -v $(shell pwd) /.cache:/home/weave/scope/.cache \
188
- -v $(shell pwd) /client:/home/weave/scope/client \
189
- -v $(shell pwd) /$(SCOPE_UI_TOOLCHAIN ) :/home/weave/scope/client/node_modules \
190
- -w /home/weave/scope/client \
191
- -u $(shell id -u ${USER}) :$(shell id -g ${USER}) \
192
- $(SCOPE_UI_BUILD_IMAGE ) yarn run lint
171
+ $(SCOPE_UI_BUILD_CMD ) $(SCOPE_UI_BUILD_IMAGE ) yarn run lint
193
172
194
173
client-start : $(SCOPE_UI_TOOLCHAIN_UPTODATE )
195
- $(SUDO ) docker run $(RM ) $(RUN_FLAGS ) --net=host \
196
- -v $(shell pwd) /.cache:/home/weave/scope/.cache \
197
- -v $(shell pwd) /client:/home/weave/scope/client \
198
- -v $(shell pwd) /$(SCOPE_UI_TOOLCHAIN ) :/home/weave/scope/client/node_modules \
174
+ $(SCOPE_UI_BUILD_CMD ) --net=host \
199
175
-e WEBPACK_SERVER_HOST \
200
- -w /home/weave/scope/client \
201
- -u $(shell id -u ${USER}) :$(shell id -g ${USER}) \
202
176
$(SCOPE_UI_BUILD_IMAGE ) yarn start
203
177
204
178
client/bundle/weave-scope.tgz : $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE )
205
- $(sudo ) docker run $(RUN_FLAGS ) \
206
- -v $(shell pwd) /.cache:/home/weave/scope/.cache \
207
- -v $(shell pwd) /client:/home/weave/scope/client \
208
- -v $(shell pwd) /$(SCOPE_UI_TOOLCHAIN ) :/home/weave/scope/client/node_modules \
209
- -v $(shell pwd) /tmp:/home/weave/tmp \
210
- -w /home/weave/scope/client \
211
- -u $(shell id -u ${USER}) :$(shell id -g ${USER}) \
212
- $(SCOPE_UI_BUILD_IMAGE ) yarn run bundle
179
+ $(SCOPE_UI_BUILD_CMD ) $(SCOPE_UI_BUILD_IMAGE ) yarn run bundle
213
180
214
181
else
215
182
@@ -230,25 +197,23 @@ client/build-external/index.html: $(SCOPE_UI_TOOLCHAIN_UPTODATE)
230
197
231
198
endif
232
199
233
- $(SCOPE_UI_BUILD_UPTODATE ) : client/Dockerfile client/package.json client/webpack.local.config.js client/webpack.production.config.js client/server.js client/.eslintrc
234
- $(SUDO ) docker build -t $(SCOPE_UI_BUILD_IMAGE ) client
235
- $(SUDO ) docker tag $(SCOPE_UI_BUILD_IMAGE ) $(SCOPE_UI_BUILD_IMAGE ) :$(IMAGE_TAG )
236
- touch $@
237
-
238
200
$(SCOPE_BACKEND_BUILD_UPTODATE ) : backend/*
239
201
$(SUDO ) docker build -t $(SCOPE_BACKEND_BUILD_IMAGE ) backend
240
202
$(SUDO ) docker tag $(SCOPE_BACKEND_BUILD_IMAGE ) $(SCOPE_BACKEND_BUILD_IMAGE ) :$(IMAGE_TAG )
241
203
touch $@
242
204
205
+ # Run aws CLI from a container image so we don't have to install Python, etc.
206
+ AWS_COMMAND =docker run $(RM ) $(RUN_FLAGS ) \
207
+ -e AWS_ACCESS_KEY_ID=$$UI_BUCKET_KEY_ID \
208
+ -e AWS_SECRET_ACCESS_KEY=$$UI_BUCKET_KEY_SECRET \
209
+ -v $(shell pwd) :/scope \
210
+ amazon/aws-cli:2.1.35
211
+
243
212
ui-upload : client/build-external/index.html
244
- AWS_ACCESS_KEY_ID=$$ UI_BUCKET_KEY_ID \
245
- AWS_SECRET_ACCESS_KEY=$$ UI_BUCKET_KEY_SECRET \
246
- aws s3 cp client/build-external/ s3://static.weave.works/scope-ui/ --recursive --exclude ' *.html'
213
+ $(AWS_COMMAND ) s3 cp /scope/client/build-external/ s3://static.weave.works/scope-ui/ --recursive --exclude ' *.html'
247
214
248
215
ui-pkg-upload : client/bundle/weave-scope.tgz
249
- AWS_ACCESS_KEY_ID=$$ UI_BUCKET_KEY_ID \
250
- AWS_SECRET_ACCESS_KEY=$$ UI_BUCKET_KEY_SECRET \
251
- aws s3 cp client/bundle/weave-scope.tgz s3://weaveworks-js-modules/weave-scope/$(shell echo $(SCOPE_VERSION ) ) /weave-scope.tgz
216
+ $(AWS_COMMAND ) s3 cp /scope/client/bundle/weave-scope.tgz s3://weaveworks-js-modules/weave-scope/$(shell echo $(SCOPE_VERSION ) ) /weave-scope.tgz
252
217
253
218
# We don't rmi images here; rm'ing the .uptodate files is enough to
254
219
# get the build images rebuilt, and rm'ing the scope exe is enough to
@@ -257,7 +222,7 @@ ui-pkg-upload: client/bundle/weave-scope.tgz
257
222
# rmi'ng images is desirable sometimes. Invoke `realclean` for that.
258
223
clean :
259
224
$(GO ) clean ./...
260
- rm -rf $(SCOPE_EXPORT ) $(SCOPE_UI_BUILD_UPTODATE ) $( SCOPE_UI_TOOLCHAIN_UPTODATE ) $(SCOPE_BACKEND_BUILD_UPTODATE ) \
225
+ rm -rf $(SCOPE_EXPORT ) $(SCOPE_UI_TOOLCHAIN_UPTODATE ) $(SCOPE_BACKEND_BUILD_UPTODATE ) \
261
226
$(SCOPE_EXE ) $(RUNSVINIT ) prog/staticui/staticui.go prog/externalui/externalui.go client/build/* .js client/build-external/* .js docker/weave .pkg \
262
227
$(CODECGEN_TARGETS ) $(CODECGEN_DIR ) /bin
263
228
@@ -274,19 +239,17 @@ clean-codecgen:
274
239
# Doing this is important for release builds.
275
240
realclean : clean
276
241
rm -rf $(SCOPE_UI_TOOLCHAIN )
277
- $(SUDO ) docker rmi -f $(SCOPE_UI_BUILD_IMAGE ) $( SCOPE_BACKEND_BUILD_IMAGE ) \
242
+ $(SUDO ) docker rmi -f $(SCOPE_BACKEND_BUILD_IMAGE ) \
278
243
$(DOCKERHUB_USER ) /scope $(DOCKERHUB_USER ) /cloud-agent \
279
244
$(DOCKERHUB_USER ) /scope:$(IMAGE_TAG ) $(DOCKERHUB_USER ) /cloud-agent:$(IMAGE_TAG ) \
280
245
weaveworks/weaveexec:$(WEAVENET_VERSION ) \
281
- ubuntu:yakkety alpine:3.5 node:6.9.0 2> /dev/null || true
246
+ ubuntu:bionic alpine:3.11 node:6.9.0 2> /dev/null || true
282
247
283
248
# Dependencies are intentionally build without enforcing any tags
284
249
# since they are build on the host
285
250
deps :
286
251
$(GO ) get -u -f \
287
- github.com/FiloSottile/gvt \
288
252
github.com/mattn/goveralls \
289
- github.com/weaveworks/github-release \
290
253
github.com/2opremio/trifles/wscat
291
254
292
255
# This target is only intended for use in Netlify CI environment for generating preview pages on feature branches and pull requests.
0 commit comments