forked from kung-foo/freki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (38 loc) · 1.42 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
VERSION := 1.1.1
NAME := freki
GH_PATH := github.com/kung-foo/$(NAME)
BUILDSTRING := $(shell git log --pretty=format:'%h' -n 1)
VERSIONSTRING := $(NAME) version $(VERSION)+$(BUILDSTRING)
OUTPUT = bin/$(NAME)
BUILD_CMD := go build -o $(OUTPUT) -ldflags "-X \"main.VERSION=$(VERSIONSTRING)\"" app/main.go
UID := $(shell id -u)
GID := $(shell id -g)
default: build
$(OUTPUT): glide.lock app/main.go *.go netfilter/*
@mkdir -p bin/
$(BUILD_CMD)
build: $(OUTPUT)
upx: build
upx -1 $(OUTPUT)
clean:
rm -rf bin/*
DOCKER_OPTS := -v "$(PWD)":/go/src/$(GH_PATH) -w /go/src/$(GH_PATH)
ALPINE_TAG := $(NAME)-build:alpine
build-docker-alpine:
docker build -t $(ALPINE_TAG) -f Dockerfile.alpine .
docker run --rm -u $(UID):$(GID) $(DOCKER_OPTS) $(ALPINE_TAG) $(BUILD_CMD)
mv $(OUTPUT) $(OUTPUT)-musl
build-docker-alpine-sh:
docker run --rm -it $(DOCKER_OPTS) $(ALPINE_TAG) ash
DEBIAN_TAG := $(NAME)-build:debian
build-docker-debian:
docker build -t $(DEBIAN_TAG) -f Dockerfile.debian .
docker run --rm -u $(UID):$(GID) $(DOCKER_OPTS) $(DEBIAN_TAG) $(BUILD_CMD)
build-docker-debian-sh:
docker run --rm -it $(DOCKER_OPTS) $(DEBIAN_TAG) bash
RUN_DC := docker-compose -f system_test/docker-compose.yml
system-test:
$(RUN_DC) up --build --abort-on-container-exit
$(RUN_DC) ps -q | xargs docker inspect -f '{{ .State.ExitCode }}' | grep -v 0 | wc -l | tr -d ' ' > /tmp/dc-exit-code.txt
$(RUN_DC) rm -f -v freki test
exit `cat /tmp/dc-exit-code.txt`