forked from stefanprodan/mgob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (82 loc) · 2.93 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
SHELL:=/bin/bash
APP_VERSION?=1.3
# build vars
BUILD_DATE:=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
REPOSITORY:=stefanprodan
#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 $(REPOSITORY)/mgob:$(APP_VERSION)"
@docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(TRAVIS_COMMIT) \
--build-arg VERSION=$(APP_VERSION) \
-t $(REPOSITORY)/mgob:$(APP_VERSION) .
travis:
@echo ">>> Building mgob:$(APP_VERSION).$(TRAVIS_BUILD_NUMBER) image"
@docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(TRAVIS_COMMIT) \
--build-arg VERSION=$(APP_VERSION).$(TRAVIS_BUILD_NUMBER) \
-t $(REPOSITORY)/mgob:$(APP_VERSION).$(TRAVIS_BUILD_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" \
$(REPOSITORY)/mgob:$(APP_VERSION).$(TRAVIS_BUILD_NUMBER) \
-ConfigPath=/config \
-StoragePath=/storage \
-TmpPath=/tmp \
-LogLevel=info
publish:
@echo $(DOCKER_PASS) | docker login -u "$(DOCKER_USER)" --password-stdin
@docker tag $(REPOSITORY)/mgob:$(APP_VERSION).$(TRAVIS_BUILD_NUMBER) $(REPOSITORY)/mgob:edge
@docker push $(REPOSITORY)/mgob:edge
release:
@echo $(DOCKER_PASS) | docker login -u "$(DOCKER_USER)" --password-stdin
@docker tag $(REPOSITORY)/mgob:$(APP_VERSION).$(TRAVIS_BUILD_NUMBER) $(REPOSITORY)/mgob:$(APP_VERSION)
@docker tag $(REPOSITORY)/mgob:$(APP_VERSION).$(TRAVIS_BUILD_NUMBER) $(REPOSITORY)/mgob:latest
@docker push $(REPOSITORY)/mgob:$(APP_VERSION)
@docker push $(REPOSITORY)/mgob:latest
run:
@echo ">>> Starting mgob container"
@docker run -dp 8090:8090 --name mgob-$(APP_VERSION) \
--restart unless-stopped \
-v "$(CONFIG):/config" \
$(REPOSITORY)/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