-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (40 loc) · 1.03 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
.PHONY : build _dockerfile publish clean clean_image run join start stop root
# IMAGE SETTINGS
IMAGE=workspace
VERS='latest'
DATE=$(shell date +%y%m%d)
NAME=$(IMAGE)
# USER SETTINGS
USER=$(shell whoami)
UID=$(shell id -u)
GID=$(shell id -g)
HOMEDIR=$(HOME)
build: clean clean_image _dockerfile
_dockerfile:
docker build \
--build-arg user=${USER} \
--build-arg uid=${UID} --build-arg gid=${GID} \
--pull -t $(IMAGE):$(VERS) .
clean:
docker container rm "$(NAME)" || :
clean_image:
docker image rm -f $(IMAGE):$(VERS) || :
run:
nohup docker run \
--name "$(NAME)" \
-v $(HOMEDIR):/home/$(USER) \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
--restart unless-stopped \
--network host \
--hostname $(NAME) \
--tty \
$(IMAGE):$(VERS) &>/dev/null &
join:
docker exec -it "$(NAME)" /bin/bash
start:
docker start -ia "$(NAME)"
stop:
docker stop "$(NAME)"
root:
# docker run -u root --name "$(NAME)" -v $(HOMEDIR):/home/$(USER) -it $(IMAGE):$(VERS)
docker exec -u root -it "$(NAME)" /bin/bash