-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
70 lines (58 loc) · 1.66 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
ifeq ($(SUDO), 1)
DOCKER=sudo docker
else
DOCKER=docker
endif
VERSION?=latest
IMGNAME?=jagdev-$(VERSION)
USERNAME=$(shell id -un)
USERID=$(shell id -u)
GROUPNAME=$(shell id -gn)
GROUPID=$(shell id -g)
GITNAME=$(shell git config user.name)
GITEMAIL=$(shell git config user.email)
BUILDARGS=
BUILDARGS+=--build-arg USERNAME=$(USERNAME)
BUILDARGS+=--build-arg USERID=$(USERID)
BUILDARGS+=--build-arg GROUPNAME=$(GROUPNAME)
BUILDARGS+=--build-arg GROUPID=$(GROUPID)
BUILDARGS+=--build-arg VERSION=$(VERSION)
ENV=
VOLUMES=
VOLUMES+=-v $(PWD)/src:/home/$(USERNAME)/src:Z
ifeq ($(shell if test -e $(HOME)/.emacs; then echo "true"; else echo "false"; fi),true)
VOLUMES+=-v $(HOME)/.emacs:/home/$(USERNAME)/.emacs:Z
endif
ifneq ($(DISPLAY),)
VOLUMES+=-v /tmp/.X11-unix:/tmp/.X11-unix:Z
ENV+=-e DISPLAY=$(DISPLAY)
endif
ifneq ($(SSH_AUTH_SOCK),)
VOLUMES+=-v $(SSH_AUTH_SOCK):/ssh-agent:Z
ENV+=-e SSH_AUTH_SOCK=/ssh-agent
BUILDARGS+=--ssh default
endif
HOSTS=
#HOSTS+=--add-host xx:yy
.PHONY: help build run
all: help
run: build
xhost +local: || true
$(DOCKER) run --rm --privileged -t -i $(VOLUMES) $(ENV) $(HOSTS) $(IMGNAME) /bin/bash
xhost -local: || true
build: Dockerfile
DOCKER_BUILDKIT=1 $(DOCKER) build -t $(IMGNAME) $(BUILDARGS) .
help:
@echo "Provide an archlinux development environment using Docker"
@echo
@echo "To build docker image:"
@echo " 'make build'"
@echo
@echo "To run docker container:"
@echo " 'make run'"
@echo
@echo "If you need to be root to run docker, then add SUDO=1 in front of the above commands"
@echo " e.g. 'SUDO=1 make run'"
@echo
@echo "The user is sudoer in the docker container. "
@echo "The password is set to be equal to 'archlinux'"