-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker
executable file
·82 lines (70 loc) · 3.08 KB
/
docker
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
#!/usr/bin/make -f
#
# \brief Docker container and image for the Genode OS Framework
# \author Stefan Kalkowski
# \date 2020-09-21
#
help:
$(ECHO)
$(ECHO) "Genode development docker container control utility"
$(ECHO)
$(ECHO) "--- available commands ---"
$(ECHO) "build - build and export genode docker image from scratch"
$(ECHO) "import - import pre-build docker image from genode.org"
$(ECHO) "run - create and run interactive genode docker container"
$(ECHO) " (user and group ids and home directory are mapped 1:1)"
$(ECHO) "admin - spawn container root instance with genode docker image"
$(ECHO) " (enables you to install additional packages)"
$(ECHO) "clean - delete genode docker image"
$(ECHO)
$(ECHO) "--- variables evaluated ---"
$(ECHO) "MAKE_JOBS - number of parallel jobs for build (default: 4)"
$(ECHO) "SUDO - optional sudo command (default: empty)"
$(ECHO) "DOCKER_CONTAINER_ARGS - additional arguments for container creation"
$(ECHO)
SUDO ?=
MAKE_JOBS ?= 4
DOCKER_CONTAINER_ARGS ?=
UID := $(shell id -u)
GID := $(shell id -g)
ECHO := @echo
DOCKER_IMAGE := genode-23.05-image:23.05
DOCKER_CONTAINER := genode-23.05
COMMON_CONTAINER_ARGS = $(DOCKER_CONTAINER_ARGS)
COMMON_CONTAINER_ARGS += --interactive --tty
ADMIN_CONTAINER_ARGS = $(COMMON_CONTAINER_ARGS)
ADMIN_CONTAINER_ARGS += --name=$(DOCKER_CONTAINER)-admin
CONTAINER_ARGS = $(COMMON_CONTAINER_ARGS)
CONTAINER_ARGS += --rm
CONTAINER_ARGS += --workdir $(HOME)
CONTAINER_ARGS += --user $(UID):$(GID)
CONTAINER_ARGS += --volume="/etc/passwd:/etc/passwd:ro"
CONTAINER_ARGS += --volume="/etc/group:/etc/group:ro"
CONTAINER_ARGS += --volume="$(HOME):$(HOME):rw"
CONTAINER_ARGS += --env DISPLAY=$(DISPLAY)
CONTAINER_ARGS += --volume "/tmp/.X11-unix:/tmp/.X11-unix"
CONTAINER_ARGS += --name=$(DOCKER_CONTAINER)
CONTAINER_ARGS += --hostname=$(shell hostname)
DOCKER_IMAGE_TAR = genode-23.05-docker-image.tar
DOCKER_IMAGE_TAR_URI = https://genode.org/files/$(DOCKER_IMAGE_TAR)
DOCKER_IMAGE_TAR_SHA = d1b1dc92cd957a43046852497a12e51081adea1a
build:
$(SUDO) docker build -t $(DOCKER_IMAGE) --build-arg JOBS=$(MAKE_JOBS) .
$(SUDO) docker save $(DOCKER_IMAGE) > $(DOCKER_IMAGE_TAR)
import:
curl -s -o $(DOCKER_IMAGE_TAR) $(DOCKER_IMAGE_TAR_URI)
$(ECHO) "$(DOCKER_IMAGE_TAR_SHA) $(DOCKER_IMAGE_TAR)" > $(DOCKER_IMAGE_TAR).sha
sha1sum -c $(DOCKER_IMAGE_TAR).sha
$(SUDO) docker load < $(DOCKER_IMAGE_TAR)
rm $(DOCKER_IMAGE_TAR) $(DOCKER_IMAGE_TAR).sha
run:
$(SUDO) docker run $(CONTAINER_ARGS) $(DOCKER_IMAGE) /bin/bash
admin:
$(SUDO) docker create $(ADMIN_CONTAINER_ARGS) $(DOCKER_IMAGE)
$(SUDO) docker start $(DOCKER_CONTAINER)-admin
$(SUDO) docker attach $(DOCKER_CONTAINER)-admin
$(SUDO) docker commit $(DOCKER_CONTAINER)-admin $(DOCKER_IMAGE)
$(SUDO) docker rm $(DOCKER_CONTAINER)-admin
clean:
$(SUDO) docker image rm $(DOCKER_IMAGE)
$(SUDO) docker image prune