forked from airdock-io/docker-oracle-jdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
54 lines (42 loc) · 1.87 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
NAMESPACE = airdock
NAME = oracle-jdk
FULLNAME = $(NAMESPACE)/$(NAME)
VERSION = jdk-8u112
.PHONY: all clean build tag_latest release debug run save start usage
all: usage build
clean:
@CID=$(docker ps -a | awk '{ print $$1 " " $$2 }' | grep $(FULLNAME) | awk '{ print $$1 }'); if [ ! -z "$$CID" ]; then echo "Removing container which reference $(FULLNAME)"; for container in $(CID); do docker rm -f $$container; done; fi;
@echo "Removing image $(FULLNAME)"
@if docker images $(FULLNAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then docker rmi -f $(FULLNAME):$(VERSION); fi
@if docker images $(FULLNAME) | awk '{ print $$2 }' | grep -q -F latest; then docker rmi -f $(FULLNAME):latest; fi
build: clean
docker build -t $(FULLNAME):$(VERSION) --rm .
tag_latest:
@docker tag $(FULLNAME):$(VERSION) $(FULLNAME):latest
release: build tag_latest
docker push $(FULLNAME)
@echo "Create a tag v-$(VERSION)"
@git tag v-$(VERSION)
@git push origin v-$(VERSION)
debug:
@docker run -t -i $(FULLNAME):$(VERSION) /bin/bash
save:
@OUTPUT_FILE = $(NAME)_$(VERSION)_`date +%Y%m%d%H%M%S`.tgz
@docker save $(FULLNAME):$(VERSION) | gzip --best --stdout > $(OUTPUT_FILE)
@echo "Image $(FULLNAME):$(VERSION) exported to $(OUTPUT_FILE)"
run:
@echo "IPAddress =" $$(docker inspect --format '{{.NetworkSettings.IPAddress}}' $$(docker run -d $(FULLNAME):$(VERSION)))
start:
@docker-machine start default
@eval "$(docker-machine env default)"
usage:
@echo "List of target"
@echo "all (default): print usage and build"
@echo "clean: remove containers and image"
@echo "build: build docker image"
@echo "tag_latest: build and tag image with 'latest'"
@echo "debug: launch a shell with this image"
@echo "save: export this image"
@echo "run: launch this image with inner command"
@echo "start: start docker machine"
@echo "usage: this help"