-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
35 lines (29 loc) · 954 Bytes
/
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
release: docker_build docker_login docker_push output
dockerId ?= lokeon
PSWD=""
DOCKER_IMAGE = $(dockerId)/kali
GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))
CODE_VERSION = $(strip $(shell cat VERSION))
ifeq ($(MAKECMDGOALS),release)
DOCKER_TAG = $(CODE_VERSION)
else
DOCKER_TAG = $(CODE_VERSION)-$(GIT_COMMIT)
endif
ifndef CODE_VERSION
$(error You need to create a VERSION file to build a release)
endif
docker_login:
docker login -u $(dockerId) -p $(PSWD)
docker_build:
docker build \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VERSION=$(CODE_VERSION) \
--build-arg VCS_URL=`git config --get remote.origin.url` \
--build-arg VCS_REF=$(GIT_COMMIT) \
-t $(DOCKER_IMAGE):$(DOCKER_TAG) .
docker_push:
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_IMAGE):latest
output:
@echo Docker Image: $(DOCKER_IMAGE):$(DOCKER_TAG)