This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (52 loc) · 1.97 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
IMAGE_NAME ?= cmdlabs/terragrunt-utils
RELEASE_VERSION = 1.2.0
BUILD_VERSION ?= testing
ifdef CI_COMMIT_REF_NAME
BUILD_VERSION=$(CI_COMMIT_REF_NAME)
endif
#Workaround for linux not supporting docker.host.internal
UNAME = $(shell uname)
ifeq ($(UNAME), Linux)
HOSTIP = --add-host=host.docker.internal:$(shell ip route | grep docker0 | awk '{print $$9}')
endif
login:
docker login -u $(DOCKER_HUB_CMDSOLUTIONS_USER) -p $(DOCKER_HUB_CMDSOLUTIONS_PASS)
PHONY: login
build:
docker build -t $(IMAGE_NAME):$(BUILD_VERSION) .
PHONY: build
test:
docker run --rm --entrypoint=terraform $(IMAGE_NAME):$(BUILD_VERSION) --help
docker run --rm --entrypoint=aws $(IMAGE_NAME):$(BUILD_VERSION) --version
docker run --rm --entrypoint=terraform-docs $(IMAGE_NAME):$(BUILD_VERSION) --help
@echo "All tests completed successfully"
PHONY: test
scan:
docker run --rm -d --name clair-db arminc/clair-db:latest
docker run --rm $(HOSTIP) -p 6060:6060 --link clair-db:postgres -d --name clair arminc/clair-local-scan:latest
clair-scanner --ip host.docker.internal $(IMAGE_NAME):$(BUILD_VERSION)
.PHONY: scan
scanClean:
docker stop clair-db; true
docker stop clair; true
.PHONY: scanClean
push: login
docker push $(IMAGE_NAME):$(BUILD_VERSION)
.PHONY: push
pushLatest: login
docker pull $(IMAGE_NAME):$(BUILD_VERSION)
docker tag $(IMAGE_NAME):$(BUILD_VERSION) $(IMAGE_NAME):latest
docker push $(IMAGE_NAME):latest
.PHONY: tagLatest
tag:
git tag -a $(RELEASE_VERSION) -m ''
git push origin $(RELEASE_VERSION)
PHONY: tag
publish:
git fetch --all
git remote add github https://$(GIT_USERNAME):$(GIT_PASSWORD)@github.com/cmdlabs/$(CI_PROJECT_NAME)
git checkout master
git pull origin master
git push --follow-tags github master
curl -X POST -H 'Content-type: application/json' --data '{"text":"A new commit has been published to Github\nProject: $(CI_PROJECT_NAME)\nRef: $(CI_COMMIT_REF_NAME)\nDiff: https://github.com/cmdlabs/$(CI_PROJECT_NAME)/commit/$(CI_COMMIT_SHA)"}' $(GIT_PUBLISHING_WEBHOOK)
PHONY: publish