-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
40 lines (33 loc) · 1.39 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
VERSION ?= $(shell git describe --tags --always )
TARGET ?= $(shell basename `git rev-parse --show-toplevel`)
TEST ?= $(shell go list ./... | grep -v /vendor/)
REPOSITORY := mattdeboer/mpp
DOCKER_IMAGE ?= ${REPOSITORY}:${VERSION}
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
REVISION ?= $(shell git rev-parse HEAD)
LD_FLAGS ?= -s -X github.com/matt-deboer/mpp/pkg/version.Name=$(TARGET) \
-X github.com/matt-deboer/mpp/pkg/version.Revision=$(REVISION) \
-X github.com/matt-deboer/mpp/pkg/version.Branch=$(BRANCH) \
-X github.com/matt-deboer/mpp/pkg/version.Version=$(VERSION)
default: test build
test:
go test -v -cover -run=$(RUN) $(TEST)
build: clean
@go build -v -o bin/$(TARGET) -ldflags "$(LD_FLAGS)+local_changes" ./pkg/server
release: clean
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
-a -tags netgo \
-a -installsuffix cgo \
-ldflags "$(LD_FLAGS)" \
-o bin/$(TARGET) ./pkg/server
ca-certificates.crt:
@-docker rm -f mpp_cacerts
@docker run --name mpp_cacerts debian:latest bash -c 'apt-get update && apt-get install -y ca-certificates'
@docker cp mpp_cacerts:/etc/ssl/certs/ca-certificates.crt .
@docker rm -f mpp_cacerts
docker: ca-certificates.crt
@echo "Building ${DOCKER_IMAGE}..."
@docker build -t ${DOCKER_IMAGE} -f Dockerfile.scratch .
@docker build -t ${DOCKER_IMAGE}-alpine -f Dockerfile.alpine .
clean:
@rm -rf bin/