forked from cs50/ide-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (44 loc) · 1.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
IMG_WKSPC=workspace
IMG_IDE=cs50/ide
CON_OFF=ide50
IP := 127.0.0.1
PLUGINS := audioplayer browser cat debug gist hex info presentation simple statuspage theme
# pick right tool for opening IDE in browser
ifeq ($(shell uname), Linux)
OPEN=xdg-open
else
OPEN=open
endif
define getplugin
@echo "\nFetching $(1)..."
@plugin_dir="files/plugins/c9.ide.cs50.$(1)"; \
mkdir -p "$$plugin_dir"; \
git clone --depth=1 "git@github.com:cs50/harvard.cs50.$(1).git" "$$plugin_dir"; \
rm -rf "$$plugin_dir/README.md" "$$plugin_dir/.git"*
endef
run:
docker run -e "IP=$(IP)" -e "PORT=8080" \
--name $(CON_OFF) -d -t \
--security-opt seccomp=unconfined \
-p 5050:5050 -p 8080:8080 -p 8081:8081 -p 8082:8082 \
$(IMG_IDE) 2>/dev/null \
|| docker start $(CON_OFF)
open:
$(OPEN) http://$(IP):5050/ide.html >/dev/null 2>&1
shell: run
docker exec -it $(CON_OFF) /bin/bash
restart:
docker restart $(CON_OFF) || true
stop:
docker stop $(CON_OFF) || true
build:
rm -rf files/plugins
mkdir files/plugins
$(foreach plugin,$(PLUGINS),$(call getplugin,$(plugin)))
rm -rf files/plugins/*/.{git,gitignore}
docker build --no-cache -t $(IMG_IDE) .
# removal
clean: stop
rm -rf files/plugins || true
docker rm $(CON_OFF) || true
docker rmi $(IMG_IDE) || true