-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.mk
49 lines (38 loc) · 915 Bytes
/
common.mk
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
# To be included in Makefiles.
# Define the variable NAME.
VENDOR ?= unit9
VERSION ?= latest
IMAGE ?= ${VENDOR}/${NAME}
DOCKERFILE ?= Dockerfile
DOCKER_RUN_ARGS ?=
DOCKER_RUN_CMD ?=
DOCKER_SH_CMD ?= bash
all: build
options:
@echo "VENDOR = ${VENDOR}"
@echo "NAME = ${NAME}"
@echo "IMAGE = ${IMAGE}"
@echo "VERSION = ${VERSION}"
@echo "DOCKER_RUN_ARGS = ${DOCKER_RUN_ARGS}"
build: ${DOCKERFILE}
@echo "BUILD ${IMAGE}:${VERSION}"
@docker build -f ${DOCKERFILE} -t ${IMAGE}:${VERSION} .
clean:
@echo "RMI ${IMAGE}:${VERSION}"
@docker rmi ${IMAGE}:${VERSION}
run:
@echo "RUN ${IMAGE}:${VERSION}"
@docker run \
--rm -ti \
--name ${NAME} \
--hostname ${NAME} \
${DOCKER_RUN_ARGS} \
${IMAGE}:${VERSION} \
${DOCKER_RUN_CMD}
shell:
@ DOCKER_RUN_CMD=${DOCKER_SH_CMD} ${MAKE} run
push:
@echo "PUSH ${IMAGE}:${VERSION}"
@docker push ${IMAGE}:${VERSION}
# All targets are phony
.PHONY: *