-
Notifications
You must be signed in to change notification settings - Fork 3
/
makefile
58 lines (47 loc) · 1.4 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
APP := phylosmith
PORT :=
CONTAINER := phylosmith_dev
SECRETS :=
GITHUB_SSH :=
GITHUB_MODULES :=
######
DOCKER_NAME := $(if $(CONTAINER),--name $(CONTAINER),)
DOCKER_PORT := $(if $(PORT),-p $(PORT):$(PORT),)
DOCKER_RUN = docker run --rm $(MODE) $(DOCKER_NAME) $(DOCKER_PORT) $(APP)
DOCKER_STOP = -docker stop $(CONTAINER) > /dev/null 2>&1
DOCKER_RM = -docker rm $(CONTAINER) > /dev/null 2>&1
define DOCKER_SECRET_ARGS
$(strip $(foreach secret,$(SECRETS),--secret id=$(word 1,$(subst :, ,$(secret))),src=$(word 2,$(subst :, ,$(secret))) ))
endef
GITHUB_SECRET := $(if $(GITHUB_SSH),$(shell echo --secret id=ssh_key,src=$(GITHUB_SSH)),)
GH_MODS := $(if $(GITHUB_MODULES),$(foreach module,$(GITHUB_MODULES), \
pip install git+ssh://[email protected]/$(module).git \
|| pip install git+https://github.com/$(module).git;),)
DOCKER_BUILD := docker build $(call DOCKER_SECRET_ARGS) $(GITHUB_SECRET) -t $(APP) .
######
.PHONY: all
all: \
docker \
docker-run
.PHONY: docker
docker:
export DOCKER_BUILDKIT=1 && $(DOCKER_BUILD)
.PHONY: docker-fresh
docker-fresh:
export DOCKER_BUILDKIT=1 && $(DOCKER_BUILD) --no-cache
.PHONY: docker-run
docker-run:
$(DOCKER_RUN)
.PHONY: docker-bg
docker-bg:
$(eval MODE = -d)
$(DOCKER_RUN)
.PHONY: docker-interactive
docker-interactive:
$(eval MODE = -it --entrypoint /bin/bash)
$(DOCKER_RUN)
.PHONY: clean
clean:
$(DOCKER_STOP) || true
$(DOCKER_RM) || true
docker image prune -f