-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
executable file
·79 lines (55 loc) · 1.77 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
VERSION ?= $(shell git describe 2>/dev/null || echo "v0.$(git rev-list --count HEAD)")
AUTHOR := ashald
PLUGIN_NAME := docker-volume-loopback
PLUGIN_FULL_NAME := ${AUTHOR}/${PLUGIN_NAME}
ROOTFS_CONTAINER := ${PLUGIN_NAME}-rootfs
ROOTFS_IMAGE := ${AUTHOR}/${ROOTFS_CONTAINER}
.PHONY: all
all: format build
.PHONY: format
format:
go fmt ./...
.PHONY: build
build:
GOOS=linux GOARCH=amd64 go build -o $(PLUGIN_NAME)
.PHONY: test
test:
./tests/run.sh
.PHONY: clean
clean:
mkdir -p ./plugin/rootfs
rm -rf ./plugin/rootfs
rm -f ./$(ROOTFS_IMAGE)
.PHONY: clean-plugin
clean-plugin:
docker plugin rm --force $(PLUGIN_FULL_NAME):$(VERSION) || true
docker plugin rm --force $(PLUGIN_FULL_NAME) || true
.PHONY: rootfs-image
rootfs-image:
docker build -t $(ROOTFS_IMAGE) .
.PHONY: rootfs
rootfs: rootfs-image
docker rm -vf $(ROOTFS_CONTAINER) || true
docker create --name $(ROOTFS_CONTAINER) $(ROOTFS_IMAGE) || true
mkdir -p ./plugin/rootfs
rm -rf ./plugin/rootfs/*
docker export $(ROOTFS_CONTAINER) | tar -x -C ./plugin/rootfs
docker rm -vf $(ROOTFS_CONTAINER)
.PHONY: plugin
plugin: rootfs
docker plugin disable $(PLUGIN_NAME) || true
docker plugin rm --force $(PLUGIN_NAME) || true
docker plugin create $(PLUGIN_NAME) ./plugin
docker plugin enable $(PLUGIN_NAME)
.PHONY: plugin-push-version
plugin-push-version: rootfs
docker plugin rm --force $(PLUGIN_FULL_NAME):$(VERSION) || true
docker plugin create $(PLUGIN_FULL_NAME):$(VERSION) ./plugin
docker plugin push $(PLUGIN_FULL_NAME):$(VERSION)
.PHONY: plugin-push-default
plugin-push-default: rootfs
docker plugin rm --force $(PLUGIN_FULL_NAME) || true
docker plugin create $(PLUGIN_FULL_NAME) ./plugin
docker plugin push $(PLUGIN_FULL_NAME)
.PHONY: plugin-push
plugin-push: plugin-push-version plugin-push-default