-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
104 lines (74 loc) · 2.24 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
### repo variables
PROJECT_USER=kaybenleroll
PROJECT_NAME=dds_soup2nuts
PROJECT_TAG=latest
IMAGE_TAG=${PROJECT_USER}/${PROJECT_NAME}:${PROJECT_TAG}
DOCKER_USER=rstudio
DOCKER_PASS=CHANGEME
DOCKER_UID=$(shell id -u)
DOCKER_GID=$(shell id -g)
RSTUDIO_PORT=8787
PROJECT_FOLDER=workshop
### Set GITHUB_USER with 'gh config set gh_user <<user>>'
GITHUB_USER=$(shell gh config get gh_user)
CONTAINER_NAME=dds-workshop
### Project build targets
.SUFFIXES: .Rmd .html .dot .png
RMD_FILES := $(wildcard *.Rmd)
HTML_FILES := $(patsubst %.Rmd,%.html,$(RMD_FILES))
all-html: $(HTML_FILES)
.Rmd.html:
Rscript -e 'rmarkdown::render("$<")'
.dot.png:
dot -Tpng -o$*.png $<
full_deps.dot:
makefile2graph all-html > full_deps.dot
depgraph: full_deps.png
exploring_retail_data.html: retrieve_retail_data.html
exploring_retail_dataexplorer.html: exploring_retail_data.html
exploring_graph_data.html: exploring_retail_data.html
initial_arules_models.html: exploring_graph_data.html exploring_retail_data.html
initial_btyd_models.html: exploring_retail_data.html
initial_rfm_models.html: exploring_retail_data.html
initial_timeseries_models.html: exploring_retail_data.html
build_models.html: initial_arules_models.html initial_btyd_models.html \
initial_rfm_models.html initial_timeseries_models.html
summary_slides.html: build_models.html
clean-html:
rm -fv *.html
clean-cache:
rm -rfv *_cache
rm -rfv *_files
mrproper: clean-html clean-cache
rm -fv data/*.rds
rm -fv data/*.csv
rm -fv data/*.xlsx
rm -fv precompute/*.rds
rm -fv full_deps.*
### Docker targets
docker-build-image: Dockerfile
docker build -t ${IMAGE_TAG} -f Dockerfile .
docker-run:
docker run --rm -d \
-p ${RSTUDIO_PORT}:8787 \
-e USER=${DOCKER_USER} \
-e PASSWORD=${DOCKER_PASS} \
-e USERID=${DOCKER_UID} \
-e GROUPID=${DOCKER_GID} \
-v "${PWD}":"/home/${DOCKER_USER}/${PROJECT_FOLDER}":rw \
--name ${CONTAINER_NAME} \
${IMAGE_TAG}
docker-bash:
docker exec -it -u ${DOCKER_USER} ${CONTAINER_NAME} bash
docker-stop:
docker stop ${CONTAINER_NAME}
docker-rm:
docker rm ${CONTAINER_NAME}
docker-start:
docker start ${CONTAINER_NAME}
docker-clean: docker-stop-all
docker rm $(shell docker ps -q -a)
docker-pull:
docker pull ${IMAGE_TAG}
docker-push:
docker push ${IMAGE_TAG}