forked from docker-archive/oscalkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (41 loc) · 1.52 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
GOOS := darwin
GOARCH := amd64
VERSION := 0.2.0
BUILD := $(shell git rev-parse --short HEAD)-dev
DATE := $(shell date "+%Y-%m-%d")
NAMESPACE := docker
REPO := oscalkit
BINARY=oscalkit_$(GOOS)_$(GOARCH)
.DEFAULT_GOAL := $(BINARY)
.PHONY: test build-docker push $(BINARY) clean generate
generate:
docker build -t $(NAMESPACE)/$(REPO):generate -f Dockerfile.generate .
docker container run \
-v $$PWD:/go/src/github.com/docker/oscalkit \
$(NAMESPACE)/$(REPO):generate \
sh -c "go generate"
test:
@echo "Running Oscalkit test Utility"
@echo "Running remaining tests"
@go test -race -coverprofile=coverage.txt -covermode=atomic -v $(shell go list ./... | grep -v "/vendor/\|/test_util/src")
build-docker:
docker image build --build-arg VERSION=$(VERSION) --build-arg BUILD=$(BUILD) --build-arg DATE=$(DATE) -t $(NAMESPACE)/$(REPO):$(VERSION)-$(BUILD) .
push: build-docker
docker image push $(NAMESPACE)/$(REPO):$(BUILD)
build:
docker image build -f Dockerfile.build \
--build-arg GOOS=$(GOOS) \
--build-arg GOARCH=$(GOARCH) \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD=$(BUILD) \
--build-arg DATE=$(DATE) \
--build-arg BINARY=$(BINARY) \
-t $(NAMESPACE)/$(REPO):$(VERSION)-$(BUILD)-builder .
# Builds binary for the OS/arch. Assumes that types have already been generated
# via the "generate" target
$(BINARY): build
$(eval ID := $(shell docker create $(NAMESPACE)/$(REPO):$(VERSION)-$(BUILD)-builder))
@docker cp $(ID):/$(BINARY) .
@docker rm $(ID) >/dev/null
clean:
if [ -f ${BINARY} ]; then rm ${BINARY}; fi