-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
36 lines (27 loc) · 999 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
36
ifeq ($(OS),Windows_NT)
ppth = $(shell cygpath -a -m -l .)
else
ppth = $(shell pwd -P)
endif
name = cloud-init
img = frontmark/$(name):latest
caps = --cap-drop ALL
sopt = --security-opt no-new-privileges
rofs = --read-only --tmpfs /tmp
vol = --mount type=bind,source='$(ppth)/datacenters',target=/datacenters,readonly
env = $(if $(DATACENTER),-e DATACENTER=$(DATACENTER),) $(if $(LOCATION),-e LOCATION=$(LOCATION),) $(if $(ACTION),-e ACTION=$(ACTION),-e ACTION=create) $(if $(SERVER),-e SERVER=$(SERVER),) $(if $(VOLUME),-e VOLUME=$(VOLUME),) $(if $(NIC),-e NIC=$(NIC),) $(if $(FIREWALLRULE),-e FIREWALLRULE=$(FIREWALLRULE),)
args = $(caps) $(sopt) $(rofs) $(vol) $(env)
.PHONY: all build run stop rm up down init reinit rerun
.DEFAULT_GOAL := all
all: build
build:
docker build --pull -t $(img) .
run:
docker run -it --rm $(args) --name $(name)1 --hostname $(name)1 $(img)
stop rm:
-docker container $@ $(name)1
up: build run
down: stop rm
init: up
reinit: down init
rerun: down run