This repository has been archived by the owner on Jan 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (57 loc) · 1.73 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
66
67
68
69
70
# image settings for the docker image name, tags and
# container name while running
IMAGE_NAME=registry.camunda.com/camunda-wine
TAGS=latest
NAME=wine
# parent image name
FROM=$(shell head -n1 Dockerfile | cut -d " " -f 2)
# the first tag and the remaining tags split up
FIRST_TAG=$(firstword $(TAGS))
ADDITIONAL_TAGS=$(wordlist 2, $(words $(TAGS)), $(TAGS))
# the image name which will be build
IMAGE=$(IMAGE_NAME):$(FIRST_TAG)
# options to use for running the image, can be extended by FLAGS variable
OPTS=--name $(NAME) -p 5900 -t $(FLAGS)
# the docker command which can be configured by the DOCKER_OPTS variable
DOCKER=docker $(DOCKER_OPTS)
# default build settings
REMOVE=true
FORCE_RM=true
NO_CACHE=false
# build the image for the first tag and tag it for additional tags
build:
$(DOCKER) build --rm=$(REMOVE) --force-rm=$(FORCE_RM) --no-cache=$(NO_CACHE) -t $(IMAGE) .
@for tag in $(ADDITIONAL_TAGS); do \
$(DOCKER) tag -f $(IMAGE) $(IMAGE_NAME):$$tag; \
done
# pull image from registry
pull:
-$(DOCKER) pull $(IMAGE)
# pull parent image
pull-from:
$(DOCKER) pull $(FROM)
# push container to registry
push:
@for tag in $(TAGS); do \
$(DOCKER) push $(IMAGE_NAME):$$tag; \
done
# pull parent image, pull image, build image and push to repository
publish: pull-from pull build push
# run container
run: rmf
$(DOCKER) run --rm $(OPTS) $(IMAGE)
# start container as daemon
daemon:
$(DOCKER) run -d $(OPTS) $(IMAGE)
# start interactive container with bash
shell:
$(DOCKER) run --rm -i $(OPTS) $(IMAGE) /bin/bash
# remove container by name
rmf:
-$(DOCKER) rm -f $(NAME)
# remove image with all tags
rmi:
@for tag in $(TAGS); do \
$(DOCKER) rmi $(IMAGE_NAME):$$tag; \
done
.PHONY: build pull pull-from push publish run daemon shell rmf rmi