-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
48 lines (41 loc) · 1.15 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
CURRENT_PATH := $(notdir $(patsubst %/,%,$(CURDIR)))
REPO_URI := PUT DOCKER REPO HERE <---------------------------------------
NAME := ${CURRENT_PATH}
TAG := $(shell git rev-parse --short HEAD)
IMG_BUILD := ${NAME}:tmp
IMG := ${REPO_URI}/${NAME}:${TAG}
LATEST := ${REPO_URI}/${NAME}:latest
CMD := bash
TEST_CMD := -t
all: push
login:
@docker log -u ${DOCKER_USER} -p ${DOCKER_PASS}
.PHONY: login
logs:
@docker logs ${NAME}_${TAG}
.PHONY: logs
run:
@docker run -it ${IMG_BUILD} ${CMD}
.PHONY: run
clean:
-@docker rm ${NAME}_${TAG}
-@docker rmi ${IMG_BUILD}
.PHONY: clean
cleanall: clean
-@docker images -q "*/${NAME}" | xargs docker image rm
.PHONY: allclean
pull:
-@docker pull ${LATEST}
@docker pull ${IMG} || exit 0 && echo Tag already exists upstream at ${IMG}, exiting ; exit 1
build: pull
@docker build -t ${IMG_BUILD} .
test: build
@docker run --name ${NAME}_${TAG} ${IMG_BUILD} ${TEST_CMD}
@docker rm ${NAME}_${TAG}
tag: test
@docker tag ${IMG_BUILD} ${IMG}
@docker tag ${IMG_BUILD} ${LATEST}
push: tag
@docker push ${IMG}
@docker push ${LATEST}
@echo ${NAME} built and pushed to ${IMG}