-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
50 lines (39 loc) · 1.09 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
IMAGE_NAME ?= tch
CONTAINER_NAME ?= TCH
DOCKER = docker
ifeq ($(OS),Windows_NT)
VERSION := $(shell type VERSION)
VOLUME ?= $(CURDIR):/TCH/VOLUME
else
VERSION = $(shell cat $(PWD)/VERSION)
VOLUME ?= $(PWD):/TCH/VOLUME
endif
DANGLING_IMAGE = $(shell $(DOCKER) images -f dangling=true -q)
LATEST_TCH_IMAGE = $(shell $(DOCKER) images --filter=reference="tch" -q)
build:
ifneq ($(LATEST_TCH_IMAGE),)
@$(DOCKER) rmi -f $(LATEST_TCH_IMAGE)
endif
@$(DOCKER) build -t $(IMAGE_NAME):$(VERSION) ./
@$(DOCKER) tag $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):latest
ifneq ($(DANGLING_IMAGE),)
@$(DOCKER) rmi $(DANGLING_IMAGE)
endif
.PHONY: build
test:
@$(DOCKER) run --name $(CONTAINER_NAME) -v $(VOLUME) -it --rm $(IMAGE_NAME):$(VERSION) -l full -c VOLUME/Examples/SortTheList/
.PHONY: test
run:
@$(DOCKER) run --name $(CONTAINER_NAME) -v $(VOLUME) -it --rm $(IMAGE_NAME):$(VERSION) $(ARGS)
.PHONY: run
version:
@echo $(VERSION)
.PHONY: version
clean:
ifneq ($(LATEST_TCH_IMAGE),)
@$(DOCKER) rmi -f $(LATEST_TCH_IMAGE)
endif
ifneq ($(DANGLING_IMAGE),)
@$(DOCKER) rmi $(DANGLING_IMAGE)
endif
.PHONY: clean