-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
52 lines (43 loc) · 2.78 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
current_dir=$(shell pwd)
version=$(PLUGIN_VERSION)
project_name=$(shell basename "${current_dir}")
APP_HOME=src/github.com/WeBankPartners/wecube-plugins-saltstack
PORT_BINDING={{ALLOCATE_PORT}}:8082
fmt:
docker run --rm -v $(current_dir):/go/src/github.com/WeBankPartners/$(project_name) --name build_$(project_name) -w /go/src/github.com/WeBankPartners/$(project_name)/ golang:1.19.1 go fmt ./...
clean:
rm -rf $(project_name)
rm -rf ./*.tar
rm -rf ./*.zip
build: clean
chmod +x ./build/*.sh
docker run --rm -v $(current_dir):/go/src/github.com/WeBankPartners/$(project_name) --name build_$(project_name) golang:1.19.1 /bin/bash /go/src/github.com/WeBankPartners/$(project_name)/build/build.sh
image: build
docker build -t $(project_name):$(version) .
package: image
sed 's/{{PLUGIN_VERSION}}/$(version)/' ./build/register.xml.tpl > ./register.xml
sed -i 's/{{IMAGENAME}}/$(project_name):$(version)/g' ./register.xml
sed -i 's/{{CONTAINERNAME}}/$(project_name)-$(version)/g' ./register.xml
sed -i 's/{{PORTBINDING}}/$(PORT_BINDING)/' ./register.xml
docker save -o image.tar $(project_name):$(version)
zip $(project_name)-$(version).zip image.tar register.xml
rm -rf $(project_name)
rm -f register.xml
rm -rf ./*.tar
docker rmi $(project_name):$(version)
upload: package
$(eval container_id:=$(shell docker run -v $(current_dir):/package -itd --entrypoint=/bin/sh minio/mc))
docker exec $(container_id) mc config host add wecubeS3 $(s3_server_url) $(s3_access_key) $(s3_secret_key)
docker exec $(container_id) mc cp /package/$(project_name)-$(version).zip wecubeS3/wecube-plugin-package-bucket
docker rm -f $(container_id)
rm -rf $(project_name)-$(version).zip
push: image
docker login -u $(dockerhub_user) -p $(dockerhub_pass) $(dockerhub_server)
docker tag $(project_name):$(version) $(dockerhub_server)/$(dockerhub_path)/wecube-saltstack:$(version)
docker rmi $(project_name):$(version)
docker push $(dockerhub_server)/$(dockerhub_path)/wecube-saltstack:$(version)
docker rmi $(dockerhub_server)/$(dockerhub_path)/wecube-saltstack:$(version)
run_container: push
docker -H $(server_addr) rm -f $(shell docker -H $(server_addr) ps -a | grep "wecube-saltstack-smoke" | awk '{print $$1}') | true
docker -H $(server_addr) pull $(dockerhub_server)/$(dockerhub_path)/wecube-saltstack:$(version)
docker -H $(server_addr) run -d --name wecube-saltstack-smoke -p 9099:80 -p 9090:8080 -p 4505:4505 -p 4506:4506 -p $(server_port):8082 -v /etc/localtime:/etc/localtime -v $(base_mount_path)/data/minions_pki:/etc/salt/pki/master/minions -v $(base_mount_path)/saltstack/logs:/home/app/saltstack/logs -v $(base_mount_path)/data:/home/app/data -e minion_master_ip=$(minion_master_ip) -e minion_passwd=$(minion_passwd) -e minion_port=$(minion_port) $(dockerhub_server)/$(dockerhub_path)/wecube-saltstack:$(version)