forked from aialferov/pause
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (53 loc) · 1.58 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
USER = openvnf
PROJECT = pause
VERSION = $(shell cat Version)
GIT_SHA = $(shell git rev-parse HEAD | cut -c1-8)
PREFIX = usr/local
BUILD_DIR = _build
BUILD_DIR_IMAGE = $(BUILD_DIR)/image
BIN_DIR = bin
BIN_PATH = $(DEST_DIR)/$(PREFIX)/$(BIN_DIR)
BIN_PATH_IN = $(BUILD_DIR)/bin
all:
mkdir -p $(BIN_PATH_IN)
GOOS=$(PLATFORM) go build \
-ldflags "-X main.version=$(VERSION) \
-X main.git_sha=$(GIT_SHA)" \
-o $(BIN_PATH_IN)/$(PROJECT) src/$(PROJECT).go
run:
$(BIN_PATH_IN)/$(PROJECT)
install:
mkdir -p $(BIN_PATH)
install -p $(BIN_PATH_IN)/$(PROJECT) $(BIN_PATH)
uninstall:
rm -f $(BIN_PATH)/$(PROJECT)
rmdir -p $(BIN_PATH) 2> /dev/null || true
clean:
rm -f $(BIN_PATH_IN)/$(PROJECT)
rmdir -p $(BIN_PATH_IN) 2> /dev/null || true
git-release:
git tag -a v$(VERSION)
git push origin v$(VERSION)
docker-build:
docker build . -t $(USER)/$(PROJECT):$(VERSION)
docker tag $(USER)/$(PROJECT):$(VERSION) $(USER)/$(PROJECT):edge
docker-push:
docker push $(USER)/$(PROJECT):$(VERSION)
docker push $(USER)/$(PROJECT):edge
docker-release:
docker tag $(USER)/$(PROJECT):$(VERSION) $(USER)/$(PROJECT):latest
docker push $(USER)/$(PROJECT):latest
docker-clean-dangling:
docker images -qf dangling=true | xargs docker rmi
docker-run:
docker run --name $(PROJECT) --rm -it \
$(USER)/$(PROJECT):$(VERSION) $(PROJECT)
docker-start:
docker run --name $(PROJECT) --rm -d \
$(USER)/$(PROJECT):$(VERSION) $(PROJECT)
docker-stop:
docker stop $(PROJECT)
distclean: docker-clean clean
.PHONY: version
version:
@echo "Version $(VERSION) (git-$(GIT_SHA))"