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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
;;; Julia/Pluto notebook system container for the run-guix-container daemon.
#!
GeneNetwork's Pluto notebooks are served by PlutoSliderServer, from
the pluto-notebook package (guix-bioinformatics/gn/packages/julia.scm,
superseding the old julia-visuals). The shared service
(julia-notebook-service-type) lives in (genenetwork services
julia-notebook) and is reused here; the container just picks the port,
the SSH setup and the container workarounds.
Build it with the channels on the load path:
base=$HOME/guix
guix system container --network \
-L $base/guix-bioinformatics \
-L $base/gn-machines \
-L $base/contrib/guix-forge/guix \
$base/gn-machines/genenetwork/containers/julia-notebook-container.scm
Preferred on hosts running the run-guix-system-container daemon
(listening on 127.0.0.1:8900): start the built container with
run-guix-container.rb --daemon 127.0.0.1:8900 <HASH>
run-guix-container.rb --daemon 127.0.0.1:8900 --log <HASH>
Then browse http://127.0.0.1:8890/ (PlutoSliderServer lists the
notebooks it serves, including the bundled gn-smoke-test.jl). Inspect
over ssh on port 2225 with the pinned ~/hello-container-key.
The notebooks are the ones bundled in pluto-notebook plus anything put
in the directory the service is pointed at (PLUTO_NOTEBOOKS_DIR). To
serve real notebooks and persist the Julia depot, add build-time host
mappings -- the container's private root cannot see the host otherwise:
guix system container --network \
--share=/home/shepherd/.julia=/var/lib/julia-notebook/.julia \
--expose=/srv/pluto-notebooks=/var/lib/julia-notebook/notebooks \
-L ... julia-notebook-container.scm
and set notebooks-directory to /var/lib/julia-notebook/notebooks. (The
Julia depot must be mounted: /var/lib/julia-notebook is recreated empty
on every container restart, so without the mount Pluto re-downloads and
recompiles its environment at each boot.)
!#
(define-module (genenetwork containers julia-notebook-container)
#:use-module (gnu)
#:use-module (genenetwork services julia-notebook)
#:use-module (genenetwork services container-ssh)
#:use-module (genenetwork packages)
#:use-module (guix gexp)
#:use-module (guix build utils)
#:use-module (gnu services base)
#:use-module (gnu services shepherd)
#:use-module (gnu services sysctl))
(use-package-modules base bash admin linux nss)
;; The pinned SSH keys live in the building user's $HOME and are
;; fetched from there at build time; container-ssh-service (shared
;; with the other containers) wires them into sshd. See the Keys
;; section of genenetwork/containers/cgit-container.scm.
;; What this container is, said once. A store path is a hash and a pid says
;; nothing; this string is the OS's issue field and the ssh banner, and the
;; shared container-ssh-service also prints it as the first line of the boot log.
(define %julia-notebook-banner
"julia-notebook-container -- Pluto notebook server (:8890, ssh :2225)\nThis is a container, not the host. Exit the shell and you are back on the\nhost; the definition is gn-machines/genenetwork/containers/julia-notebook-container.scm.\n")
(operating-system
(host-name "julia-notebook-container")
(issue %julia-notebook-banner)
(timezone "Etc/UTC")
(locale "en_US.utf8")
(bootloader (bootloader-configuration
(bootloader grub-bootloader)
(targets '("/dev/sdX"))))
(file-systems (cons (file-system
(device (file-system-label "does-not-matter"))
(mount-point "/")
(type "ext4"))
%base-file-systems))
;; Minimal package set: pluto-notebook comes in through the service,
;; ssh tools through the openssh service and 'herd' through the
;; essential shepherd service. nss-certs is used directly by the
;; service (SSL_CERT_FILE points into its store item).
(packages (list bash coreutils shadow grep procps nss-certs))
;; Run PID 1 with the self-pipe signal variant: see
;; shepherd-for-containers in (genenetwork packages). Everything
;; else about the system's shepherd is the stock one.
(essential-services
(modify-services (operating-system-default-essential-services
this-operating-system)
(shepherd-root-service-type config =>
(shepherd-configuration
(inherit config)
(shepherd shepherd-for-containers)))))
(services
(append
(list
;; PlutoSliderServer's own HTTP listener (no nginx in front).
(service julia-notebook-service-type
(julia-notebook-configuration
(port "8890"))))
;; SSH on port 2225: password-less root login with
;; hello-container-key, the pinned ECDSA host key (not generated
;; at boot) and the /var/empty fix -- all shared with the other
;; containers via container-ssh-service.
(container-ssh-service #:port-number 2225 #:banner %julia-notebook-banner)
(list
;; In a container sysctl (writes /proc/sys) and udev (coldplug on
;; the static /dev the container runtime sets up) are useless and
;; their start-up hangs the whole boot: urandom-seed requires
;; udev, user-processes requires urandom-seed, and ssh-daemon
;; requires user-processes. Provide no-ops instead.
(simple-service 'container-sysctl
shepherd-root-service-type
(list (shepherd-service
(provision '(sysctl))
(one-shot? #t)
(start #~(const #t)))))
(simple-service 'container-udev
shepherd-root-service-type
(list (shepherd-service
(provision '(udev))
(one-shot? #t)
(start #~(const #t))))))
(modify-services %base-services
;; Drop the guix service: its activation runs 'guix archive
;; --generate-key' at every boot, which stalls the container
;; boot; a minimal container does not need guix-daemon anyway.
(delete guix-service-type)
(delete sysctl-service-type)
(delete udev-service-type)))))
|