This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathsite.mk
80 lines (69 loc) · 2.42 KB
/
site.mk
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
# site.mk defines how to build and test 'site api' component of Gravity
#
# Examples:
#
# make site
# make test-site
# make clean-site
#
# NOTES:
# Tests need Vagrant-based k8s cluster to be up and running.
# 'make site-test' will try to bring it up for you.
#
.PHONY: site test clear-docker prepare-vagrant clean-site site-clean sample-apps
# These variables point to Kubernetes-master server running on
# Vagrant (assets/site/Vagrantfile).
#
# WARNING: they're used outside of this make file : tests call os.Getenv()
K8S_IP=10.0.10.100
KUBEAPI=$(K8S_IP):8080
ETCDAPI=$(K8S_IP):2379
REGISTRY=$(K8S_IP):5000
ASSETSDIR=assets/site
SITEPACKAGES=$$(find lib/site -type d)
#
# 'make site' builds the Gravity site and its sample app
#
site: build/sitectl
build/sitectl: $(shell find tool lib -type f -name *.go)
@mkdir -p build
go install github.com/gravitational/gravity/tool/sitectl
cp -f $(GOPATH)/bin/sitectl build/
@echo "done --> ./build/sitectl"
# runs 'site' tests
test-site: site-test
site-test: site sample-apps clear-docker
@for package in $(SITEPACKAGES) ; do \
echo "\nTesting $$package ..." ;\
go test -v $(REPO)/$$package ;\
done
# builds a sample applicatin tarbal. this includes building Docker images,
# exporting them into .tar files and creating a resulting tarball
sample-apps: build/sample-app.tar.gz $(ASSETSDIR)/fixtures/tiny-image/tiny-binary\:5.0.0.tar
build/sample-app.tar.gz:
@mkdir -p build
cd $(ASSETSDIR)/fixtures/sample-app/images/bash-app; make
cd $(ASSETSDIR)/fixtures/sample-app/images/sample-app; make
cd $(ASSETSDIR)/fixtures/sample-app; tar -czf ../../../../build/sample-app.tar.gz *
$(ASSETSDIR)/fixtures/tiny-image/tiny-binary\:5.0.0.tar:
make -C $(ASSETSDIR)/fixtures/tiny-image
# checks if vagrant-based k8s cluster is up and running and starts it
# if it's not
prepare-vagrant:
@if [ ! $$(which ruby) ] ; then \
echo "ERROR:\nRuby is not found. Ruby is needed to launch Vagrant-based Kubernetes cluster to run tests\n" ;\
exit 1 ;\
fi
@ruby $(ASSETSDIR)/test_helper.rb
clear-docker: prepare-vagrant
@docker rmi $$(docker images -f "dangling=true" -q) 2>/dev/null || true
# deletes temporary data created by site building/testing
site-clean: clean-site
clean-site:
@mkdir -p build
rm -rf build/sample-app.tar.gz
find assets/site/fixtures -name "*tar" -delete
rm -rf build/sitectl
# Ev's "dev shortcuts"
z: sample-apps
go test -v -short github.com/gravitational/gravity/lib/site/docker