-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
65 lines (55 loc) · 1.25 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
GOC=go build
GOFLAGS=-a -ldflags '-s'
CGOR=CGO_ENABLED=0
VER_NUM=latest
DOCKER_OPTIONS="--no-cache"
IMAGE_NAME=docker.io/unixvoid/beacon:$(VER_NUM)
REDIS_DB_HOST_DIR="/tmp/"
GIT_HASH=$(shell git rev-parse HEAD | head -c 10)
all: beacon
beacon: beacon.go
$(GOC) beacon.go
dependencies:
go get github.com/gorilla/mux
go get golang.org/x/crypto/sha3
go get gopkg.in/gcfg.v1
go get gopkg.in/redis.v3
go get github.com/unixvoid/glogger
run:
cd beacon && go run \
beacon.go \
provision.go \
remove.go \
rotate.go \
update.go
stat:
mkdir -p bin/
$(CGOR) $(GOC) $(GOFLAGS) -o bin/beacon-$(GIT_HASH)-linux-amd64 beacon/*.go
test:
go test -v beacon/*.go
install: stat
cp beacon /usr/bin
docker:
$(MAKE) stat
mkdir stage.tmp/
cp bin/beacon* stage.tmp/
cp deps/rootfs.tar.gz stage.tmp/
cp deps/Dockerfile stage.tmp/
sed -i "s/<DIFF>/$(GIT_HASH)/g" stage.tmp/Dockerfile
chmod +x deps/run.sh
cp deps/run.sh stage.tmp/
cp beacon/config.gcfg stage.tmp/
cd stage.tmp/ && \
sudo docker build $(DOCKER_OPTIONS) -t $(IMAGE_NAME) .
@echo "$(IMAGE_NAME) built"
dockerrun:
sudo docker run \
-d \
-p 8808:8808 \
--name beacon \
-v $(REDIS_DB_HOST_DIR):/redisbackup/:rw \
unixvoid/beacon
sudo docker logs -f beacon
clean:
rm -rf bin/
rm -rf stage.tmp/