-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (48 loc) · 1.63 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
DOCKER_IMAGE_LATEST = hello
DOCKER_IMAGE = $(DOCKER_IMAGE_LATEST):$(REVISION_SHORT)
PROJECT_ID = betterplace-183212
DOCKER_PORT ?= 8080
REMOTE_LATEST_TAG := eu.gcr.io/${PROJECT_ID}/$(DOCKER_IMAGE_LATEST)
REMOTE_TAG = eu.gcr.io/$(PROJECT_ID)/$(DOCKER_IMAGE)
REVISION := $(shell git rev-parse HEAD)
REVISION_SHORT := $(shell echo $(REVISION) | head -c 7)
GOPATH := $(shell pwd)/gospace
GOBIN = $(GOPATH)/bin
.EXPORT_ALL_VARIABLES:
all: hello
hello: cmd/hello/main.go *.go
go build -o $@ $<
local: hello
./hello
fetch:
go mod download
setup: fake-package fetch
fake-package:
rm -rf $(GOPATH)/src/github.com/betterplace/betterplace-hello
mkdir -p $(GOPATH)/src/github.com/betterplace
ln -s $(shell pwd) $(GOPATH)/src/github.com/betterplace/betterplace-hello
clean:
@rm -f hello tags
clobber: clean
@rm -rf $(GOPATH)/*
tags: clean
@gotags -tag-relative=false -silent=true -R=true -f $@ . $(GOPATH)
build-info:
@echo $(REMOTE_TAG)
build:
docker build --pull -t $(DOCKER_IMAGE) -t $(DOCKER_IMAGE_LATEST) .
$(MAKE) build-info
build-force:
docker build --pull -t $(DOCKER_IMAGE) -t $(DOCKER_IMAGE_LATEST) --no-cache .
$(MAKE) build-info
server: build
docker run -it -e PORT=$(DOCKER_PORT) -p $(DOCKER_PORT):$(DOCKER_PORT) $(DOCKER_IMAGE)
push: build
gcloud auth configure-docker
docker tag $(DOCKER_IMAGE) $(REMOTE_TAG)
docker push $(REMOTE_TAG)
push-latest: push
docker tag ${DOCKER_IMAGE} ${REMOTE_LATEST_TAG}
docker push ${REMOTE_LATEST_TAG}
grype: build
@docker run --pull always --rm --volume /var/run/docker.sock:/var/run/docker.sock --name Grype anchore/grype:latest --add-cpes-if-none --by-cve --fail-on low "$(DOCKER_IMAGE)"