forked from lispmeister/rpxp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (42 loc) · 1.6 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
DOCKER_IMAGE_VERSION=0.0.1
DOCKER_IMAGE_NAME=lispmeister/rpxp
DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)
current_dir = $(shell pwd)
config ?= debug
default: build
print-% : ; @echo $* = $($*)
build:
docker build --build-arg PONYC_CONFIG=$(config) -t $(DOCKER_IMAGE_TAGNAME) .
docker run --rm -v $(current_dir):/build-export $(DOCKER_IMAGE_TAGNAME) -U `id -u -n` -u 1000 -G `id -g -n` -g 1000 cp -r /build $(pwd)/build-export
docker build -t $(DOCKER_IMAGE_TAGNAME) --file=./Dockerfile.runtime .
rm -rf build
docker tag -f $(DOCKER_IMAGE_TAGNAME) $(DOCKER_IMAGE_NAME):latest
push:
docker push $(DOCKER_IMAGE_NAME)
test:
docker run --rm $(DOCKER_IMAGE_TAGNAME) echo 'Success.'
version:
ponyc --version
exited := $(shell docker ps -a -q -f status=exited)
untagged := $(shell (docker images | grep "^<none>" | awk -F " " '{print $$3}'))
dangling := $(shell docker images -f "dangling=true" -q)
tag := $(shell docker images | grep "$(DOCKER_IMAGE_NAME)" | grep "$(DOCKER_IMAGE_VERSION)" |awk -F " " '{print $$3}')
latest := $(shell docker images | grep "$(DOCKER_IMAGE_NAME)" | grep "latest" | awk -F " " '{print $$3}')
clean:
ifneq ($(strip $(latest)),)
@echo "Removing latest $(latest) image"
docker rmi "$(DOCKER_IMAGE_NAME):latest"
endif
ifneq ($(strip $(tag)),)
@echo "Removing tag $(tag) image"
docker rmi "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)"
endif
ifneq ($(strip $(exited)),)
@echo "Cleaning exited containers: $(exited)"
docker rm -v $(exited)
endif
ifneq ($(strip $(dangling)),)
@echo "Cleaning dangling images: $(dangling)"
docker rmi $(dangling)
endif
@echo 'Done cleaning.'