forked from maxisam/mgob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
138 lines (120 loc) · 4.49 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
SHELL:=/bin/bash
APP_VERSION?=1.5
# build vars
BUILD_DATE:=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
#run vars
CONFIG:=$$(pwd)/test/config
TRAVIS:=$$(pwd)/test/travis
# go tools
PACKAGES:=$(shell go list ./... | grep -v '/vendor/')
VETARGS:=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -rangeloops -shift -structtags -unsafeptr
build:
@echo ">>> Building $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)"
@docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(GITHUB_SHA) \
--build-arg VERSION=$(APP_VERSION) \
-t $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION) .
aws:
@echo ">>> Building $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)"
@docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(GITHUB_SHA) \
--build-arg VERSION=$(APP_VERSION) \
--build-arg EN_AWS_CLI=true \
--build-arg EN_AZURE=false \
--build-arg EN_GCLOUD=false \
--build-arg EN_MINIO=false \
--build-arg EN_RCLONE=false \
--build-arg EN_GPG=true \
-t $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)-aws .
azure:
@echo ">>> Building $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)"
@docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(GITHUB_SHA) \
--build-arg VERSION=$(APP_VERSION) \
--build-arg EN_AWS_CLI=false \
--build-arg EN_AZURE=true \
--build-arg EN_GCLOUD=false \
--build-arg EN_MINIO=false \
--build-arg EN_RCLONE=false \
--build-arg EN_GPG=true \
-t $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)-azure .
gcloud:
@echo ">>> Building $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)"
@docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(GITHUB_SHA) \
--build-arg VERSION=$(APP_VERSION) \
--build-arg EN_AWS_CLI=false \
--build-arg EN_AZURE=false \
--build-arg EN_GCLOUD=true \
--build-arg EN_MINIO=false \
--build-arg EN_RCLONE=false \
--build-arg EN_GPG=true \
-t $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)-gcloud .
ci:
@echo ">>> Building mgob:$(APP_VERSION).$(GITHUB_RUN_NUMBER) image"
@docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(GITHUB_SHA) \
--build-arg VERSION=$(APP_VERSION).$(GITHUB_RUN_NUMBER) \
-t $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION).$(GITHUB_RUN_NUMBER) .
@echo ">>> Starting mgob container"
@docker run -d --net=host --name mgob \
--restart unless-stopped \
-v "$(TRAVIS):/config" \
-v "/tmp/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key:ro" \
-v "/tmp/ssh_host_rsa_key.pub:/etc/ssh/ssh_host_rsa_key.pub:ro" \
$(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION).$(GITHUB_RUN_NUMBER) \
-ConfigPath=/config \
-StoragePath=/storage \
-TmpPath=/tmp \
-LogLevel=info
publish:
@echo $(DOCKER_PASS) | docker login -u "$(DOCKER_USER)" --password-stdin
@docker tag $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION).$(GITHUB_RUN_NUMBER) $(GITHUB_REPOSITORY_OWNER)/mgob:edge
@docker push $(GITHUB_REPOSITORY_OWNER)/mgob:edge
release:
@echo $(DOCKER_PASS) | docker login -u "$(DOCKER_USER)" --password-stdin
@docker tag $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION).$(GITHUB_RUN_NUMBER) $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)
@docker tag $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION).$(GITHUB_RUN_NUMBER) $(GITHUB_REPOSITORY_OWNER)/mgob:latest
@docker push $(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION)
@docker push $(GITHUB_REPOSITORY_OWNER)/mgob:latest
run:
@echo ">>> Starting mgob container"
@docker run -dp 8090:8090 --name mgob-$(APP_VERSION) \
--restart unless-stopped \
-v "$(CONFIG):/config" \
$(GITHUB_REPOSITORY_OWNER)/mgob:$(APP_VERSION) \
-ConfigPath=/config \
-StoragePath=/storage \
-TmpPath=/tmp \
-LogLevel=info
backend:
@docker run -dp 20022:22 --name mgob-sftp \
atmoz/sftp:alpine test:test:::backup
@docker run -dp 20099:9000 --name mgob-s3 \
-e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
minio/minio server /export
@mc config host add local http://localhost:20099 \
AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY S3v4
@sleep 5
@mc mb local/backup
fmt:
@echo ">>> Running go fmt $(PACKAGES)"
@go fmt $(PACKAGES)
vet:
@echo ">>> Running go vet $(VETARGS)"
@go list ./... \
| grep -v /vendor/ \
| cut -d '/' -f 4- \
| xargs -n1 \
go tool vet $(VETARGS) ;\
if [ $$? -ne 0 ]; then \
echo ""; \
echo "go vet failed"; \
fi
.PHONY: build