-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
89 lines (80 loc) · 2 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
#Variables
SHELL := /bin/bash
pwd ?= `pwd`
ALIAS ?= ciao
UID := `id -u`
GID := `id -g`
EMACS_PATH ?= $(pwd)/.emacs.d
WORKSPACE_PATH ?= $(pwd)/WS
WORKSPACE_DOCKER_PATH ?= /home/emacs/workspace
# Find stopped images
EXISTS := $(shell docker ps -a -q -f name=$(ALIAS))
# Find running images
RUNNED := $(shell docker ps -q -f name=$(ALIAS))
# Find old images
STALE_IMAGES := $(shell docker images | grep "<none>" | awk '{print($$3)}')
# Remove previous containers, build new and run ciao
all: clean build ciao
# Build a new container
build:
@docker build \
--file Dockerfile \
--tag $(ALIAS) \
--build-arg WORKSPACE_ARG=$(WORKSPACE_DOCKER_PATH) \
.
# Run emacs with ciao module on GUI
run:
@docker run \
-d \
--name $(ALIAS) \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
-e DISPLAY="unix$$DISPLAY" \
-e UNAME="emacser" \
-e GNAME="emacsers" \
-e UID="1000" \
-e GID="1000" \
-e WORKSPACE=$(WORKSPACE_DOCKER_PATH) \
-v $(WORKSPACE_PATH):$(WORKSPACE_DOCKER_PATH):rw \
$(ALIAS) emacs
# Run ciao container
ciao: clean
@docker run -ti --rm --name $(ALIAS) \
-e UNAME="emacser" \
-e GNAME="emacsers" \
-e UID="1000" \
-e GID="1000" \
-e WORKSPACE=$(WORKSPACE_DOCKER_PATH) \
-v $(WORKSPACE_PATH):$(WORKSPACE_DOCKER_PATH):rw \
$(ALIAS) /bin/bash
# Clean ciao containers
clean:
ifneq "$(RUNNED)" ""
@docker kill $(ALIAS)
endif
-@docker rm $(ALIAS)
ifneq "$(STALE_IMAGES)" ""
@docker rmi -f $(STALE_IMAGES)
endif
# Remove ciao images
cleanAll:
-@docker rmi $(ALIAS)
# Old
original:
$(eval ALIAS := emacs-ori)
ifneq "$(RUNNED)" ""
$(shell docker stop $(ALIAS))
endif
ifneq "$(EXISTS)" ""
$(shell docker container rm $(ALIAS))
endif
docker run -ti --name $(ALIAS) \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
-e DISPLAY="unix$$DISPLAY" \
-e UNAME="emacser" \
-e GNAME="emacsers" \
-e UID="$(UID_tmp)" \
-e GID="$(GID_tmp)" \
-v $(EMACS_PATH):/home/emacs/.emacs.d \
-e WORKSPACE=$(WORKSPACE_DOCKER_PATH) \
-v $(WORKSPACE_PATH):$(WORKSPACE_DOCKER_PATH):rw \
jare/emacs emacs