-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (52 loc) · 1.79 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
##
## tempoR Makefile
## ###############
##
## Builds 2 different docker images for the tempo data shiny-base and shiny-server
##
## build-base: is a shiny server instance adding the R packages needed for tempo
## build: adds the tempo R files to the shiny-base image for a selfcontained image
##
## dev: is a dev mode that mounts the R files to the shiny-base image for testing
##
REPO := europe-north1-docker.pkg.dev/verifa-metrics/tempo
TAG := $(shell git describe --tags --always --dirty=-dev)
IMAGE := $(REPO)/tempo-dashboard
# Hardcoded because we don't push this anywhere
BASE_IMAGE := verifa/shiny-base:test
TEMPO_RENVIRON ?= $(HOME)/.Renviron
default: shiny-server
##
## Targets
##
## help : prints this help
.PHONY : help
help : Makefile
@sed -n 's/^##//p' $<
## build-base : builds a docker image w the necessary R packages
build-base:
docker build --target base -t $(BASE_IMAGE) .
## build : builds a docker images for publication that contains our
## : shiny files and configuration files
build:
# If .Renviron exists locally, use it, otherwise fetch from home directory
# or the file set by TEMPO_RENVIRON
if [ ! -f .Renviron ]; then \
cp $(TEMPO_RENVIRON) .Renviron; \
fi
docker build --build-arg TEMPO_RENVIRON=.Renviron -t $(IMAGE):$(TAG) .
push: build
docker push $(IMAGE):$(TAG)
docker tag $(IMAGE):$(TAG) $(IMAGE):latest
docker push $(IMAGE):latest
## dev : runs the base docker image and mounts local files for dev mode
dev: build-base
docker run --rm -p 3838:3838 \
-v ${PWD}/index.html:/srv/shiny-server/index.html \
-v ${PWD}/shiny/:/srv/shiny-server/shiny/ \
-v ${PWD}/.Renviron:/home/shiny/.Renviron \
-u shiny \
$(BASE_IMAGE)
## run : runs the tempo-dashboard locally
run: build
docker run --rm -p 3838:3838 $(IMAGE):$(TAG)