forked from nuclio/nuclio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
818 lines (694 loc) · 29.5 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
# Copyright 2017 The Nuclio Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GO_VERSION := $(shell go version | cut -d " " -f 3)
GOPATH ?= $(shell go env GOPATH)
OS_NAME = $(shell uname)
KUBECONFIG := $(if $(KUBECONFIG),$(KUBECONFIG),$(HOME)/.kube/config)
# upstream repo
NUCLIO_DOCKER_REPO ?= quay.io/nuclio
NUCLIO_CACHE_REPO ?= ghcr.io/nuclio
# dockerfile base image
NUCLIO_BASE_IMAGE_NAME ?= gcr.io/iguazio/golang
NUCLIO_BASE_IMAGE_TAG ?= 1.19
NUCLIO_BASE_ALPINE_IMAGE_NAME ?= gcr.io/iguazio/golang
NUCLIO_BASE_ALPINE_IMAGE_TAG ?= 1.19-alpine3.17
# get default os / arch from go env
NUCLIO_DEFAULT_OS := $(shell go env GOOS)
ifeq ($(GOARCH), arm)
NUCLIO_DEFAULT_ARCH := armhf
else ifeq ($(GOARCH), arm64)
NUCLIO_DEFAULT_ARCH := arm64
else
NUCLIO_DEFAULT_ARCH := $(shell go env GOARCH || echo amd64)
endif
ifeq ($(OS_NAME), Linux)
NUCLIO_DEFAULT_TEST_HOST := $(shell docker network inspect bridge | grep "Gateway" | grep -o '"[^"]*"$$')
# On EC2 we don't have gateway, use default
ifeq ($(NUCLIO_DEFAULT_TEST_HOST),)
NUCLIO_DEFAULT_TEST_HOST := "172.17.0.1"
endif
else
NUCLIO_DEFAULT_TEST_HOST := "docker.for.mac.host.internal"
endif
NUCLIO_OS := $(if $(NUCLIO_OS),$(NUCLIO_OS),$(NUCLIO_DEFAULT_OS))
NUCLIO_ARCH := $(if $(NUCLIO_ARCH),$(NUCLIO_ARCH),$(NUCLIO_DEFAULT_ARCH))
NUCLIO_LABEL := $(if $(NUCLIO_LABEL),$(NUCLIO_LABEL),latest)
NUCLIO_CACHE_LABEL := $(if $(NUCLIO_CACHE_LABEL),$(NUCLIO_CACHE_LABEL),unstable)
NUCLIO_TEST_HOST := $(if $(NUCLIO_TEST_HOST),$(NUCLIO_TEST_HOST),$(NUCLIO_DEFAULT_TEST_HOST))
NUCLIO_VERSION_GIT_COMMIT = $(shell git rev-parse HEAD)
NUCLIO_PATH ?= $(shell pwd)
NUCLIO_VERSION_INFO = {\"git_commit\": \"$(NUCLIO_VERSION_GIT_COMMIT)\", \"label\": \"$(NUCLIO_LABEL)\"}
# Dockerized tests variables - not available for changes
NUCLIO_DOCKER_TEST_DOCKERFILE_PATH := test/docker/Dockerfile
NUCLIO_DOCKER_TEST_TAG := nuclio/tester
# Add labels to docker images
NUCLIO_DOCKER_LABELS = --label nuclio.version_info="$(NUCLIO_VERSION_INFO)"
NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_LABEL)-$(NUCLIO_ARCH)
NUCLIO_DOCKER_IMAGE_CACHE_TAG=$(NUCLIO_CACHE_LABEL)-$(NUCLIO_ARCH)-cache
NUCLIO_DOCKER_IMAGE_CACHE_ALPINE_TAG=$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)-alpine
# Link flags
GO_LINK_FLAGS ?= -s -w
GO_LINK_FLAGS_INJECT_VERSION := $(GO_LINK_FLAGS) \
-X github.com/v3io/version-go.gitCommit=$(NUCLIO_VERSION_GIT_COMMIT) \
-X github.com/v3io/version-go.label=$(NUCLIO_LABEL) \
-X github.com/v3io/version-go.arch=$(NUCLIO_ARCH)
# Nuclio test timeout
NUCLIO_GO_TEST_TIMEOUT ?= "30m"
# Docker client cli to be used
NUCLIO_DOCKER_CLIENT_VERSION ?= 19.03.14
ifeq ($(NUCLIO_ARCH), armhf)
NUCLIO_DOCKER_CLIENT_ARCH ?= armhf
else ifeq ($(NUCLIO_ARCH), arm64)
NUCLIO_DOCKER_CLIENT_ARCH ?= aarch64
else
NUCLIO_DOCKER_CLIENT_ARCH ?= x86_64
endif
# alpine is commonly used by controller / dlx / autoscaler
ifeq ($(NUCLIO_ARCH), armhf)
NUCLIO_DOCKER_ALPINE_IMAGE ?= gcr.io/iguazio/arm32v7/alpine:3.17
else ifeq ($(NUCLIO_ARCH), arm64)
NUCLIO_DOCKER_ALPINE_IMAGE ?= gcr.io/iguazio/arm64v8/alpine:3.17
else
NUCLIO_DOCKER_ALPINE_IMAGE ?= gcr.io/iguazio/alpine:3.17
endif
#
# Must be first target
#
.PHONY: all
all:
$(error "Please pick a target (run 'make targets' to view targets)")
#
# Version resources
#
.PHONY: helm-publish
helm-publish:
$(eval HELM_PUBLISH_COMMIT_MESSAGE := "Releasing chart $(shell helm inspect chart hack/k8s/helm/nuclio | yq eval '.version' -)")
@echo Fetching branch
@rm -rf /tmp/nuclio-helm
@git clone -b gh-pages --single-branch [email protected]:nuclio/nuclio.git /tmp/nuclio-helm
@echo Creating package and updating index
@helm package -d /tmp/nuclio-helm/charts hack/k8s/helm/nuclio
@cd /tmp/nuclio-helm/charts && helm repo index --merge index.yaml --url https://nuclio.github.io/nuclio/charts/ .
@echo Publishing
@cd /tmp/nuclio-helm/charts && git add --all && git commit -m $(HELM_PUBLISH_COMMIT_MESSAGE) && git push origin
@echo Done
#
# Build helpers
#
# tools get built with the specified OS/arch and inject version
GO_BUILD_TOOL_WORKDIR = /nuclio
GO_BUILD_NUCTL = go build -a -installsuffix cgo -ldflags="$(GO_LINK_FLAGS_INJECT_VERSION)"
#
# Rules
#
.PHONY: build
build: docker-images tools
@echo Done.
DOCKER_IMAGES_RULES ?= \
controller \
dashboard \
processor \
autoscaler \
dlx \
handler-builder-golang-onbuild \
handler-builder-java-onbuild \
handler-builder-ruby-onbuild \
handler-builder-python-onbuild \
handler-builder-dotnetcore-onbuild \
handler-builder-nodejs-onbuild
DOCKER_IMAGES_CACHE ?=
.PHONY: docker-images
docker-images: $(DOCKER_IMAGES_RULES)
@echo Done.
.PHONY: pull-docker-images-cache
pull-docker-images-cache:
@printf '%s\n' $(DOCKER_IMAGES_CACHE) | xargs -n 1 -P 5 docker pull
.PHONY: push-docker-images-cache
push-docker-images-cache:
@printf '%s\n' $(DOCKER_IMAGES_CACHE) | xargs -n 1 -P 5 docker push
.PHONY: tools
tools: ensure-gopath nuctl
@echo Done.
.PHONY: push-docker-images
push-docker-images: print-docker-images
@echo "Pushing images concurrently"
@echo $(IMAGES_TO_PUSH) | xargs -n 1 -P 5 docker push
@echo Done.
.PHONY: save-docker-images
save-docker-images: print-docker-images
@echo "Saving Nuclio docker images"
docker save $(IMAGES_TO_PUSH) | pigz --fast > nuclio-docker-images-$(NUCLIO_LABEL)-$(NUCLIO_ARCH).tar.gz
.PHONY: load-docker-images
load-docker-images: print-docker-images
@echo "Load Nuclio docker images"
docker load -i nuclio-docker-images-$(NUCLIO_LABEL)-$(NUCLIO_ARCH).tar.gz
.PHONY: print-docker-images
pull-docker-images: print-docker-images
@echo "Pull Nuclio docker images"
@echo $(IMAGES_TO_PUSH) | xargs -n 1 -P 5 docker pull
.PHONY: retag-docker-images
retag-docker-images: print-docker-images
$(eval NUCLIO_NEW_LABEL ?= retagged)
$(eval NUCLIO_NEW_LABEL = ${NUCLIO_NEW_LABEL}-${NUCLIO_ARCH})
@echo "Retagging Nuclio docker images with ${NUCLIO_NEW_LABEL}"
echo $(IMAGES_TO_PUSH) | xargs -P 5 -I{} sh -c 'image="{}"; docker tag $$image $$(echo $$image | cut -d : -f 1):$(NUCLIO_NEW_LABEL)'
@echo "Done"
.PHONY: print-docker-images
print-docker-images:
@# env to determine whether to print only first image
$(eval PRINT_FIRST_IMAGE ?= false)
@for image in $(IMAGES_TO_PUSH); do \
echo $$image ; \
if [ "$(PRINT_FIRST_IMAGE)" = "true" ]; then \
break ; \
fi ; \
done
.PHONY: print-docker-images-cache
print-docker-images-cache:
@echo "Nuclio Docker images cache:"
@for image in $(DOCKER_IMAGES_CACHE); do \
echo $$image; \
done
.PHONY: print-docker-image-rules-json
print-docker-image-rules-json:
@/bin/echo -n "["
@for image in $(DOCKER_IMAGES_RULES); do \
/bin/echo -n "{\"image_rule\": \"$$image\"}" ; \
if [ "$$image" != "$(lastword $(DOCKER_IMAGES_RULES))" ]; then \
/bin/echo -n "," ; \
fi ; \
done
@/bin/echo -n "]"
#
# Tools
#
NUCLIO_NUCTL_CREATE_SYMLINK := $(if $(NUCLIO_NUCTL_CREATE_SYMLINK),$(NUCLIO_NUCTL_CREATE_SYMLINK),true)
NUCTL_BIN_NAME = nuctl-$(NUCLIO_LABEL)-$(NUCLIO_OS)-$(NUCLIO_ARCH)
NUCTL_TARGET = $(GOPATH)/bin/nuctl
.PHONY: nuctl
nuctl: ensure-gopath build-builder
docker run \
--volume $(GOPATH)/bin:/go/bin \
--env GOOS=$(NUCLIO_OS) \
--env GOARCH=$(NUCLIO_ARCH) \
$(NUCLIO_DOCKER_REPO)/nuclio-builder:$(NUCLIO_DOCKER_IMAGE_TAG) \
$(GO_BUILD_NUCTL) -o /go/bin/$(NUCTL_BIN_NAME) cmd/nuctl/main.go
ifeq ($(NUCLIO_NUCTL_CREATE_SYMLINK), true)
@rm -f $(NUCTL_TARGET)
@ln -sF $(GOPATH)/bin/$(NUCTL_BIN_NAME) $(NUCTL_TARGET)
endif
.PHONY: nuctl-bin
nuctl-bin: ensure-gopath
CGO_ENABLED=0 $(GO_BUILD_NUCTL) -o $(NUCLIO_PATH)/$(NUCTL_BIN_NAME) cmd/nuctl/main.go
NUCLIO_DOCKER_PROCESSOR_IMAGE_NAME=$(NUCLIO_DOCKER_REPO)/processor:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_PROCESSOR_IMAGE_NAME_CACHE=$(NUCLIO_CACHE_REPO)/processor:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
.PHONY: processor
processor: build-builder
docker build \
--build-arg NUCLIO_GO_LINK_FLAGS_INJECT_VERSION="$(GO_LINK_FLAGS_INJECT_VERSION)" \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(NUCLIO_DOCKER_PROCESSOR_IMAGE_NAME_CACHE) \
--file cmd/processor/Dockerfile \
--tag $(NUCLIO_DOCKER_PROCESSOR_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_PROCESSOR_IMAGE_NAME_CACHE) \
.
ifneq ($(filter processor,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_PROCESSOR_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_PROCESSOR_IMAGE_NAME_CACHE))
endif
#
# Dockerized services
#
# Controller
NUCLIO_DOCKER_CONTROLLER_IMAGE_NAME=$(NUCLIO_DOCKER_REPO)/controller:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_CONTROLLER_IMAGE_NAME_CACHE=$(NUCLIO_CACHE_REPO)/controller:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
.PHONY: controller
controller: build-builder
docker build \
--build-arg ALPINE_IMAGE=$(NUCLIO_DOCKER_ALPINE_IMAGE) \
--build-arg NUCLIO_GO_LINK_FLAGS_INJECT_VERSION="$(GO_LINK_FLAGS_INJECT_VERSION)" \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(NUCLIO_CACHE_REPO)/controller:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG) \
--file cmd/controller/Dockerfile \
--tag $(NUCLIO_DOCKER_CONTROLLER_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_CONTROLLER_IMAGE_NAME_CACHE) \
$(NUCLIO_DOCKER_LABELS) .
ifneq ($(filter controller,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_CONTROLLER_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_CONTROLLER_IMAGE_NAME_CACHE))
endif
# Dashboard
NUCLIO_DOCKER_DASHBOARD_IMAGE_NAME = $(NUCLIO_DOCKER_REPO)/dashboard:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_DASHBOARD_IMAGE_NAME_CACHE = $(NUCLIO_CACHE_REPO)/dashboard:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
NUCLIO_DOCKER_DASHBOARD_UHTTPC_ARCH ?= $(NUCLIO_ARCH)
ifeq ($(NUCLIO_ARCH), armhf)
NUCLIO_DOCKER_DASHBOARD_NGINX_BASE_IMAGE ?= gcr.io/iguazio/arm32v7/nginx:1.21.5-alpine
else ifeq ($(NUCLIO_ARCH), arm64)
NUCLIO_DOCKER_DASHBOARD_NGINX_BASE_IMAGE ?= gcr.io/iguazio/arm64v8/nginx:1.21.5-alpine
else
NUCLIO_DOCKER_DASHBOARD_NGINX_BASE_IMAGE ?= gcr.io/iguazio/nginx:1.23-alpine
endif
.PHONY: dashboard
dashboard: build-builder
docker build \
--build-arg DOCKER_CLI_ARCH=$(NUCLIO_DOCKER_CLIENT_ARCH) \
--build-arg DOCKER_CLI_VERSION=$(NUCLIO_DOCKER_CLIENT_VERSION) \
--build-arg NGINX_IMAGE=$(NUCLIO_DOCKER_DASHBOARD_NGINX_BASE_IMAGE) \
--build-arg NUCLIO_DOCKER_ALPINE_IMAGE=$(NUCLIO_DOCKER_ALPINE_IMAGE) \
--build-arg NUCLIO_GO_LINK_FLAGS_INJECT_VERSION="$(GO_LINK_FLAGS_INJECT_VERSION)" \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(NUCLIO_DOCKER_DASHBOARD_IMAGE_NAME_CACHE) \
--file cmd/dashboard/docker/Dockerfile \
--tag $(NUCLIO_DOCKER_DASHBOARD_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_DASHBOARD_IMAGE_NAME_CACHE) \
$(NUCLIO_DOCKER_LABELS) .
ifneq ($(filter dashboard,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_DASHBOARD_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_DASHBOARD_IMAGE_NAME_CACHE))
endif
# Scaler
NUCLIO_DOCKER_SCALER_IMAGE_NAME=$(NUCLIO_DOCKER_REPO)/autoscaler:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_SCALER_IMAGE_NAME_CACHE=$(NUCLIO_CACHE_REPO)/autoscaler:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
.PHONY: autoscaler
autoscaler: build-builder
docker build \
--build-arg ALPINE_IMAGE=$(NUCLIO_DOCKER_ALPINE_IMAGE) \
--build-arg NUCLIO_GO_LINK_FLAGS_INJECT_VERSION="$(GO_LINK_FLAGS_INJECT_VERSION)" \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(NUCLIO_DOCKER_SCALER_IMAGE_NAME_CACHE) \
--file cmd/autoscaler/Dockerfile \
--tag $(NUCLIO_DOCKER_SCALER_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_SCALER_IMAGE_NAME_CACHE) \
$(NUCLIO_DOCKER_LABELS) .
ifneq ($(filter autoscaler,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_SCALER_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_SCALER_IMAGE_NAME_CACHE))
endif
# Dlx
NUCLIO_DOCKER_DLX_IMAGE_NAME=$(NUCLIO_DOCKER_REPO)/dlx:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_DLX_IMAGE_NAME_CACHE=$(NUCLIO_CACHE_REPO)/dlx:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
.PHONY: dlx
dlx: build-builder
docker build \
--build-arg ALPINE_IMAGE=$(NUCLIO_DOCKER_ALPINE_IMAGE) \
--build-arg NUCLIO_GO_LINK_FLAGS_INJECT_VERSION="$(GO_LINK_FLAGS_INJECT_VERSION)" \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(NUCLIO_DOCKER_DLX_IMAGE_NAME_CACHE) \
--file cmd/dlx/Dockerfile \
--tag $(NUCLIO_DOCKER_DLX_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_DLX_IMAGE_NAME_CACHE) \
$(NUCLIO_DOCKER_LABELS) .
ifneq ($(filter dlx,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_DLX_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_DLX_IMAGE_NAME_CACHE))
endif
#
# Onbuild images
#
# Python
NUCLIO_DOCKER_HANDLER_BUILDER_PYTHON_ONBUILD_IMAGE_NAME=\
$(NUCLIO_DOCKER_REPO)/handler-builder-python-onbuild:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_HANDLER_BUILDER_PYTHON_ONBUILD_IMAGE_NAME_CACHE=\
$(NUCLIO_CACHE_REPO)/handler-builder-python-onbuild:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
PIP_REQUIRE_VIRTUALENV=false
.PHONY: handler-builder-python-onbuild
handler-builder-python-onbuild:
docker build \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--cache-from $(NUCLIO_DOCKER_HANDLER_BUILDER_PYTHON_ONBUILD_IMAGE_NAME_CACHE) \
--file pkg/processor/build/runtime/python/docker/onbuild/Dockerfile \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_PYTHON_ONBUILD_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_PYTHON_ONBUILD_IMAGE_NAME_CACHE) \
.
ifneq ($(filter handler-builder-python-onbuild,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_PYTHON_ONBUILD_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_HANDLER_BUILDER_PYTHON_ONBUILD_IMAGE_NAME_CACHE))
endif
# Go
NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_IMAGE_NAME=\
$(NUCLIO_DOCKER_REPO)/handler-builder-golang-onbuild:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME=\
$(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_IMAGE_NAME)-alpine
NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_IMAGE_NAME_CACHE=\
$(NUCLIO_CACHE_REPO)/handler-builder-golang-onbuild:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME_CACHE=\
$(NUCLIO_CACHE_REPO)/handler-builder-golang-onbuild:$(NUCLIO_DOCKER_IMAGE_CACHE_ALPINE_TAG)
.PHONY: handler-builder-golang-onbuild-alpine
handler-builder-golang-onbuild-alpine: build-builder
docker build \
--build-arg NUCLIO_GO_LINK_FLAGS_INJECT_VERSION="$(GO_LINK_FLAGS_INJECT_VERSION)" \
--build-arg NUCLIO_BASE_ALPINE_IMAGE_NAME=$(NUCLIO_BASE_ALPINE_IMAGE_NAME) \
--build-arg NUCLIO_BASE_ALPINE_IMAGE_TAG=$(NUCLIO_BASE_ALPINE_IMAGE_TAG) \
--cache-from $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME_CACHE) \
--file pkg/processor/build/runtime/golang/docker/onbuild/Dockerfile.alpine \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME_CACHE) \
.
.PHONY: handler-builder-golang-onbuild
handler-builder-golang-onbuild: build-builder handler-builder-golang-onbuild-alpine
docker build \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_GO_LINK_FLAGS_INJECT_VERSION="$(GO_LINK_FLAGS_INJECT_VERSION)" \
--build-arg NUCLIO_BASE_IMAGE_NAME=$(NUCLIO_BASE_IMAGE_NAME) \
--build-arg NUCLIO_BASE_IMAGE_TAG=$(NUCLIO_BASE_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--cache-from $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_IMAGE_NAME_CACHE) \
--file pkg/processor/build/runtime/golang/docker/onbuild/Dockerfile \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_IMAGE_NAME_CACHE) \
.
ifneq ($(filter handler-builder-golang-onbuild,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_IMAGE_NAME))
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_IMAGE_NAME_CACHE))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME_CACHE))
endif
ifneq ($(filter handler-builder-golang-onbuild-alpine,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME_CACHE))
endif
ifneq ($(filter handler-builder-golang-onbuild-alpine,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_GOLANG_ONBUILD_ALPINE_IMAGE_NAME))
endif
# NodeJS
NUCLIO_DOCKER_HANDLER_BUILDER_NODEJS_ONBUILD_IMAGE_NAME=\
$(NUCLIO_DOCKER_REPO)/handler-builder-nodejs-onbuild:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_HANDLER_BUILDER_NODEJS_ONBUILD_IMAGE_NAME_CACHE=\
$(NUCLIO_CACHE_REPO)/handler-builder-nodejs-onbuild:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
.PHONY: handler-builder-nodejs-onbuild
handler-builder-nodejs-onbuild:
docker build \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--file pkg/processor/build/runtime/nodejs/docker/onbuild/Dockerfile \
--cache-from $(NUCLIO_DOCKER_HANDLER_BUILDER_NODEJS_ONBUILD_IMAGE_NAME_CACHE) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_NODEJS_ONBUILD_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_NODEJS_ONBUILD_IMAGE_NAME_CACHE) \
.
ifneq ($(filter handler-builder-nodejs-onbuild,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_NODEJS_ONBUILD_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_HANDLER_BUILDER_NODEJS_ONBUILD_IMAGE_NAME_CACHE))
endif
# Ruby
NUCLIO_DOCKER_HANDLER_BUILDER_RUBY_ONBUILD_IMAGE_NAME=\
$(NUCLIO_DOCKER_REPO)/handler-builder-ruby-onbuild:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_HANDLER_BUILDER_RUBY_ONBUILD_IMAGE_NAME_CACHE=\
$(NUCLIO_CACHE_REPO)/handler-builder-ruby-onbuild:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
.PHONY: handler-builder-ruby-onbuild
handler-builder-ruby-onbuild:
docker build \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--file pkg/processor/build/runtime/ruby/docker/onbuild/Dockerfile \
--cache-from $(NUCLIO_DOCKER_HANDLER_BUILDER_RUBY_ONBUILD_IMAGE_NAME_CACHE) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_RUBY_ONBUILD_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_RUBY_ONBUILD_IMAGE_NAME_CACHE) \
.
ifneq ($(filter handler-builder-ruby-onbuild,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_RUBY_ONBUILD_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_HANDLER_BUILDER_RUBY_ONBUILD_IMAGE_NAME_CACHE))
endif
# .NetCore
NUCLIO_DOCKER_HANDLER_BUILDER_DOTNETCORE_ONBUILD_IMAGE_NAME=\
$(NUCLIO_DOCKER_REPO)/handler-builder-dotnetcore-onbuild:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_HANDLER_BUILDER_DOTNETCORE_ONBUILD_IMAGE_NAME_CACHE=\
$(NUCLIO_CACHE_REPO)/handler-builder-dotnetcore-onbuild:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
NUCLIO_ONBUILD_DOTNETCORE_DOCKERFILE_PATH = pkg/processor/build/runtime/dotnetcore/docker/onbuild/Dockerfile
.PHONY: handler-builder-dotnetcore-onbuild
handler-builder-dotnetcore-onbuild: processor
docker build \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--cache-from $(NUCLIO_DOCKER_HANDLER_BUILDER_DOTNETCORE_ONBUILD_IMAGE_NAME_CACHE) \
--file $(NUCLIO_ONBUILD_DOTNETCORE_DOCKERFILE_PATH) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_DOTNETCORE_ONBUILD_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_DOTNETCORE_ONBUILD_IMAGE_NAME_CACHE) \
.
ifneq ($(filter handler-builder-dotnetcore-onbuild,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_DOTNETCORE_ONBUILD_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_HANDLER_BUILDER_DOTNETCORE_ONBUILD_IMAGE_NAME_CACHE))
endif
# Java
NUCLIO_DOCKER_HANDLER_BUILDER_JAVA_ONBUILD_IMAGE_NAME=\
$(NUCLIO_DOCKER_REPO)/handler-builder-java-onbuild:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_HANDLER_BUILDER_JAVA_ONBUILD_IMAGE_NAME_CACHE=\
$(NUCLIO_CACHE_REPO)/handler-builder-java-onbuild:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
.PHONY: handler-builder-java-onbuild
handler-builder-java-onbuild:
docker build \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--cache-from $(NUCLIO_DOCKER_HANDLER_BUILDER_JAVA_ONBUILD_IMAGE_NAME_CACHE) \
--file pkg/processor/build/runtime/java/docker/onbuild/Dockerfile \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_JAVA_ONBUILD_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_HANDLER_BUILDER_JAVA_ONBUILD_IMAGE_NAME_CACHE) \
.
ifneq ($(filter handler-builder-java-onbuild,$(DOCKER_IMAGES_RULES)),)
$(eval IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_JAVA_ONBUILD_IMAGE_NAME))
$(eval DOCKER_IMAGES_CACHE += $(NUCLIO_DOCKER_HANDLER_BUILDER_JAVA_ONBUILD_IMAGE_NAME_CACHE))
endif
NUCLIO_DOCKER_BUILDER_IMAGE_NAME=\
$(NUCLIO_DOCKER_REPO)/nuclio-builder:$(NUCLIO_DOCKER_IMAGE_TAG)
NUCLIO_DOCKER_BUILDER_IMAGE_NAME_CACHE=\
$(NUCLIO_CACHE_REPO)/nuclio-builder:$(NUCLIO_DOCKER_IMAGE_CACHE_TAG)
.PHONY: build-builder
build-builder:
docker build \
--build-arg NUCLIO_BASE_IMAGE_NAME=$(NUCLIO_BASE_IMAGE_NAME) \
--build-arg NUCLIO_BASE_IMAGE_TAG=$(NUCLIO_BASE_IMAGE_TAG) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(NUCLIO_DOCKER_BUILDER_IMAGE_NAME_CACHE) \
--file hack/docker/build/builder/Dockerfile \
--tag $(NUCLIO_DOCKER_BUILDER_IMAGE_NAME) \
--tag $(NUCLIO_DOCKER_BUILDER_IMAGE_NAME_CACHE) \
.
$(eval DOCKER_IMAGES_CACHE += $(filter-out $(DOCKER_IMAGES_CACHE),$(NUCLIO_DOCKER_BUILDER_IMAGE_NAME_CACHE)))
#
# Misc
#
.PHONY: fmt
fmt:
gofmt -s -w .
golangci-lint run --fix
.PHONY: lint
lint: modules ensure-test-files-annotated
@echo Installing linters...
@test -e $(GOPATH)/bin/impi || \
(mkdir -p $(GOPATH)/bin && \
curl -s https://api.github.com/repos/pavius/impi/releases/latest \
| grep -i "browser_download_url.*impi.*$(OS_NAME)" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -O $(GOPATH)/bin/impi -qi - \
&& chmod +x $(GOPATH)/bin/impi)
@test -e $(GOPATH)/bin/golangci-lint || \
(curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.50.1)
@echo Verifying imports...
$(GOPATH)/bin/impi \
--local github.com/nuclio/nuclio/ \
--scheme stdLocalThirdParty \
--skip pkg/platform/kube/apis \
--skip pkg/platform/kube/client \
./cmd/... ./pkg/... ./hack/...
@echo Linting...
$(GOPATH)/bin/golangci-lint run -v
@echo Done.
.PHONY: ensure-test-files-annotated
ensure-test-files-annotated:
$(eval test_files_missing_build_annotations=$(strip $(shell find . -type f -name '*_test.go' -exec bash -c "grep -m 1 -L '//go:build ' {} | grep go" \;)))
@if [ -n "$(test_files_missing_build_annotations)" ]; then \
echo "Found go test files without build annotations: "; \
echo $(test_files_missing_build_annotations); \
echo "!!! Go test files must be annotated with '//go:build test_<x>' !!!"; \
exit 1; \
fi
@echo "All go test files have //go:build test_X annotation"
@exit $(.SHELLSTATUS)
#
# Testing
#
.PHONY: benchmarking
benchmarking:
$(eval NUCLIO_BENCHMARKING_RUNTIMES ?= all)
@python3 hack/scripts/benchmark/benchmark.py --nuctl-platform local --runtimes $(NUCLIO_BENCHMARKING_RUNTIMES)
.PHONY: functiontemplates
functiontemplates: modules ensure-gopath
go run -tags=function_templates_generator pkg/dashboard/functiontemplates/generator/generator.go
.PHONY: generate-crds
generate-crds: build-builder
docker build \
--file hack/scripts/generate-crds/Dockerfile \
--build-arg NUCLIO_LABEL=$(NUCLIO_LABEL) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--tag nuclio/crds:latest .
docker run \
--rm \
--volume $(shell pwd)/hack:/nuclio/hack \
--volume $(shell pwd)/pkg:/output \
--workdir /nuclio \
nuclio/crds:latest
.PHONY: test-unit
test-unit: modules ensure-gopath
go test -race -tags=test_unit -v ./cmd/... ./pkg/... -short
.PHONY: test-k8s-nuctl
test-k8s-nuctl:
NUCTL_EXTERNAL_IP_ADDRESSES=$(if $(NUCTL_EXTERNAL_IP_ADDRESSES),$(NUCTL_EXTERNAL_IP_ADDRESSES),"localhost") \
NUCTL_RUN_REGISTRY=$(NUCTL_REGISTRY) \
NUCTL_PLATFORM=kube \
NUCTL_NAMESPACE=$(if $(NUCTL_NAMESPACE),$(NUCTL_NAMESPACE),"default") \
go test -tags="test_integration,test_kube" -v github.com/nuclio/nuclio/pkg/nuctl/... -p 1 --timeout $(NUCLIO_GO_TEST_TIMEOUT)
.PHONY: test-docker-nuctl
test-docker-nuctl:
NUCTL_PLATFORM=local \
go test -tags="test_integration,test_local" -v github.com/nuclio/nuclio/pkg/nuctl/... -p 1 --timeout $(NUCLIO_GO_TEST_TIMEOUT)
.PHONY: test-undockerized
test-undockerized: ensure-gopath
go test \
-tags="test_integration,test_local" \
-v \
-p 1 \
--timeout $(NUCLIO_GO_TEST_TIMEOUT) \
./cmd/... ./pkg/...
.PHONY: test-k8s-undockerized
test-k8s-undockerized: ensure-gopath
@# nuctl is running by "test-k8s-nuctl" target and requires specific set of env
go test \
-tags="test_integration,test_kube" \
-v \
-p 1 \
--timeout $(NUCLIO_GO_TEST_TIMEOUT) \
$(shell go list -tags="test_integration,test_kube" ./cmd/... ./pkg/... | grep -v nuctl)
.PHONY: test-broken-undockerized
test-broken-undockerized: ensure-gopath
go test \
-tags="test_integration,test_broken" \
-v \
-p 1 \
--timeout $(NUCLIO_GO_TEST_TIMEOUT) \
./cmd/... ./pkg/...
.PHONY: test
test: build-test
$(eval NUCLIO_TEST_MAKE_TARGET ?= $(if $(NUCLIO_TEST_BROKEN),"test-broken-undockerized","test-undockerized"))
@docker run \
--rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(GOPATH)/bin:/go/bin \
--volume $(NUCLIO_PATH):$(GO_BUILD_TOOL_WORKDIR) \
--volume /tmp:/tmp \
--workdir $(GO_BUILD_TOOL_WORKDIR) \
--env NUCLIO_TEST_HOST=$(NUCLIO_TEST_HOST) \
--env NUCLIO_VERSION_GIT_COMMIT=$(NUCLIO_VERSION_GIT_COMMIT) \
--env NUCLIO_LABEL=$(NUCLIO_LABEL) \
--env NUCLIO_ARCH=$(NUCLIO_ARCH) \
--env NUCLIO_OS=$(NUCLIO_OS) \
--env NUCLIO_GO_TEST_TIMEOUT=$(NUCLIO_GO_TEST_TIMEOUT) \
--env NUCLIO_TEST_HOST_PATH=$(NUCLIO_PATH) \
$(NUCLIO_DOCKER_TEST_TAG) \
/bin/bash -c "make $(NUCLIO_TEST_MAKE_TARGET)"
.PHONY: test-k8s
test-k8s: build-test
NUCLIO_TEST_KUBECONFIG=$(if $(NUCLIO_TEST_KUBECONFIG),$(NUCLIO_TEST_KUBECONFIG),$(KUBECONFIG)) \
docker run \
--rm \
--network host \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(GOPATH)/bin:/go/bin \
--volume $(NUCLIO_PATH):$(GO_BUILD_TOOL_WORKDIR) \
--volume /tmp:/tmp \
--volume $(NUCLIO_TEST_KUBECONFIG)/:/kubeconfig \
--workdir $(GO_BUILD_TOOL_WORKDIR) \
--env NUCLIO_TEST_HOST=$(NUCLIO_TEST_HOST) \
--env NUCLIO_VERSION_GIT_COMMIT=$(NUCLIO_VERSION_GIT_COMMIT) \
--env NUCLIO_LABEL=$(NUCLIO_LABEL) \
--env NUCLIO_ARCH=$(NUCLIO_ARCH) \
--env NUCLIO_TEST_REGISTRY_URL=$(NUCLIO_TEST_REGISTRY_URL) \
--env NUCLIO_OS=$(NUCLIO_OS) \
--env MINIKUBE_HOME=$(MINIKUBE_HOME) \
--env NUCLIO_GO_TEST_TIMEOUT=$(NUCLIO_GO_TEST_TIMEOUT) \
--env KUBECONFIG=/kubeconfig \
--env NUCLIO_TEST_KUBE_DEFAULT_INGRESS_HOST=$(NUCLIO_TEST_KUBE_DEFAULT_INGRESS_HOST) \
$(NUCLIO_DOCKER_TEST_TAG) \
/bin/bash -c "make test-k8s-undockerized"
# Runs from host to allow full control over Kubernetes cluster
.PHONY: test-k8s-functional
test-k8s-functional:
go test \
-tags="test_kube,test_functional" \
-v \
-p 1 \
--timeout $(NUCLIO_GO_TEST_TIMEOUT) \
$(shell go list -tags="test_kube,test_functional" ./cmd/... ./pkg/...)
.PHONY: build-test
build-test: build-builder
$(eval NUCLIO_TEST_KUBECTL_CLI_VERSION ?= v1.23.8)
$(eval NUCLIO_TEST_KUBECTL_CLI_ARCH ?= $(if $(filter $(NUCLIO_ARCH),amd64),amd64,arm64))
docker build \
--build-arg GOARCH=$(NUCLIO_ARCH) \
--build-arg NUCLIO_DOCKER_IMAGE_TAG=$(NUCLIO_DOCKER_IMAGE_TAG) \
--build-arg DOCKER_CLI_ARCH=$(NUCLIO_DOCKER_CLIENT_ARCH) \
--build-arg DOCKER_CLI_VERSION=$(NUCLIO_DOCKER_CLIENT_VERSION) \
--build-arg NUCLIO_DOCKER_REPO=$(NUCLIO_DOCKER_REPO) \
--build-arg KUBECTL_CLI_ARCH=$(NUCLIO_TEST_KUBECTL_CLI_ARCH) \
--build-arg KUBECTL_CLI_VERSION=$(NUCLIO_TEST_KUBECTL_CLI_VERSION) \
--file $(NUCLIO_DOCKER_TEST_DOCKERFILE_PATH) \
--tag $(NUCLIO_DOCKER_TEST_TAG) .
#
# Test runtime wrappers
#
.PHONY: test-nodejs
test-nodejs:
docker run \
--rm \
--volume $(NUCLIO_PATH)/pkg/processor/runtime/nodejs/js:/nuclio/nodejs \
--volume $(NUCLIO_PATH)/test:/nuclio/test \
--workdir /nuclio/nodejs \
--env RUN_MODE=CI \
node:16-alpine \
sh -c 'npm install && npm run lint && npm run test'
.PHONY: test-python
test-python:
@set -e; \
for runtime in 3.9 3.8 3.7 3.6; do \
docker build \
--build-arg PYTHON_IMAGE_TAG=$$runtime \
--build-arg CACHEBUST=$(shell date +%s) \
--file pkg/processor/runtime/python/test/Dockerfile \
. ;\
done
#
# Go env
#
.PHONY: ensure-gopath
ensure-gopath:
ifndef GOPATH
$(error GOPATH must be set)
endif
.PHONY: modules
modules: ensure-gopath
@echo Getting go modules
@go mod download
.PHONY: targets
targets:
@awk -F: '/^[^ \t="]+:/ && !/PHONY/ {print $$1}' Makefile | sort -u