-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.cloud
More file actions
52 lines (42 loc) · 1.37 KB
/
Makefile.cloud
File metadata and controls
52 lines (42 loc) · 1.37 KB
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
name := rstudio
project ?= $(shell gcloud config get-value project)
user ?= $(shell git config --global user.name | tr '[:upper:] ' '[:lower:]-')
registry ?= eu.gcr.io
image ?= ${name}-${user}
machine ?= n2-standard-8
zone ?= europe-west1-b
all: shell
alias:
@echo "alias ${name}='make -f \"${PWD}/Makefile.cloud\"'"
build:
docker build --tag ${name} .
docker tag ${name} ${registry}/${project}/${image}
docker push ${registry}/${project}/${image}
create:
gcloud compute instances create-with-container ${image} \
--container-image ${registry}/${project}/${image} \
--boot-disk-size 200 \
--create-disk name=${image}-pd-ssd,size=200,type=pd-ssd,auto-delete=yes \
--container-mount-disk name=${image}-pd-ssd,mount-path=/home/${name}/projects \
--container-env DISABLE_AUTH=true \
--container-restart-policy never \
--machine-type ${machine} \
--no-restart-on-failure \
--scopes default,bigquery,compute-rw,storage-rw \
--zone ${zone}
delete:
gcloud compute instances delete ${image} \
--delete-disks all \
--zone ${zone} \
--quiet
shell:
@echo 'Address: http://localhost:8787/'
@echo
gcloud compute ssh ${image} \
--zone ${zone} \
-- \
-L 8787:localhost:8787 \
'docker exec --interactive --tty $$(docker ps -q --filter="name=${image}") zsh'
%:
gcloud beta compute instances $@ ${image} --zone ${zone}
.PHONY: alias all build create delete shell