forked from jessfraz/onion
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (66 loc) · 2.91 KB
/
Makefile
File metadata and controls
89 lines (66 loc) · 2.91 KB
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
.PHONY: build clean dbuild drun dtor dtest-build dtest fmt lint shell test validate vet
# set the graph driver as the current graphdriver if not set
DOCKER_GRAPHDRIVER := $(if $(DOCKER_GRAPHDRIVER),$(DOCKER_GRAPHDRIVER),$(shell docker info | grep "Storage Driver" | sed 's/.*: //'))
# env vars passed through directly to test build scripts
DOCKER_ENVS := \
-e DOCKER_GRAPHDRIVER=$(DOCKER_GRAPHDRIVER) \
-e DOCKER_STORAGE_OPTS \
# to allow `make BIND_DIR=. shell` or `make BIND_DIR= test`
# (default to no bind mount if DOCKER_HOST is set)
# note: BINDDIR is supported for backwards-compatibility here
BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,logs))
DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/var/log/libnetwork-container")
# This allows the test suite to be able to run without worrying about the underlying fs used by the container running the daemon (e.g. aufs-on-aufs), so long as the host running the container is running a supported fs.
# The volume will be cleaned up when the container is removed due to `--rm`.
# Note that `BIND_DIR` will already be set to `bundles` if `DOCKER_HOST` is not set (see above BIND_DIR line), in such case this will do nothing since `DOCKER_MOUNT` will already be set.
DOCKER_MOUNT := $(if $(DOCKER_MOUNT),$(DOCKER_MOUNT),-v "/var/log/libnetwork-container")
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
DOCKER_IMAGE := libnetwork-container-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
# if this session isn't interactive, then we don't want to allocate a
# TTY, which would fail, but if it is interactive, we do want to attach
# so that the user can send e.g. ^C through.
INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
endif
DOCKER_RUN := docker run --rm -i $(DOCKER_FLAGS) $(DOCKER_MOUNT) --privileged $(DOCKER_ENVS) "$(DOCKER_IMAGE)"
DOCKER_RUN_CI := docker run --rm -i $(DOCKER_FLAGS) --entrypoint make --privileged $(DOCKER_ENVS) "$(DOCKER_IMAGE)"
all: build
build:
go build $(shell go list ./... | grep -v /vendor/)
clean:
rm -rf logs
ci: dtest-build
$(DOCKER_RUN_CI) test
dbuild:
@docker build --rm --force-rm -t flungo/libnetwork-container .
drun:
@docker run -d \
--name libnetwork-container \
--cap-add NET_ADMIN \
--net host \
-v /run/docker/plugins:/run/docker/plugins \
-v /var/run/docker.sock:/var/run/docker.sock \
flungo/libnetwork-container -d
dtor:
@docker run -d \
--net host \
--name tor-router \
jess/tor-router
dtest-build: logs
docker build --rm --force-rm -t "$(DOCKER_IMAGE)" -f $(CURDIR)/Dockerfile.test $(CURDIR)
dtest: dtest-build
$(DOCKER_RUN)
fmt:
@gofmt -s -l . | grep -v vendor | tee /dev/stderr
lint:
@golint ./... | grep -v vendor | tee /dev/stderr
logs:
mkdir -p logs
shell: dtest-build
$(DOCKER_RUN) bash
test: validate
go test -v $(shell go list ./... | grep -v vendor)
validate: fmt lint vet
vet:
go vet $(shell go list ./... | grep -v vendor)