gnu: igt-gpu-tools: Don't use NAME in source URI.
[jackhill/guix/guix.git] / gnu / packages / docker.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages docker)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (gnu packages)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system go)
30 #:use-module (guix build-system python)
31 #:use-module (guix utils)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages check)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages glib)
37 #:use-module (gnu packages golang)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages python-web)
42 #:use-module (gnu packages python-xyz)
43 #:use-module (gnu packages version-control)
44 #:use-module (gnu packages virtualization))
45
46 (define %docker-version "18.09.0")
47
48 (define-public python-docker-py
49 (package
50 (name "python-docker-py")
51 (version "1.10.6")
52 (source
53 (origin
54 (method url-fetch)
55 (uri (pypi-uri "docker-py" version))
56 (sha256
57 (base32
58 "05f49f6hnl7npmi7kigg0ibqk8s3fhzx1ivvz1kqvlv4ay3paajc"))))
59 (build-system python-build-system)
60 ;; TODO: Tests require a running Docker daemon.
61 (arguments '(#:tests? #f))
62 (inputs
63 `(("python-requests" ,python-requests)
64 ("python-six" ,python-six)
65 ("python-websocket-client" ,python-websocket-client)))
66 (home-page "https://github.com/docker/docker-py/")
67 (synopsis "Python client for Docker")
68 (description "Docker-Py is a Python client for the Docker container
69 management tool.")
70 (license license:asl2.0)))
71
72 (define-public python-dockerpty
73 (package
74 (name "python-dockerpty")
75 (version "0.3.4")
76 (source
77 (origin
78 (method url-fetch)
79 (uri (pypi-uri "dockerpty" version))
80 (sha256
81 (base32
82 "0za6rr349641wv76ww9l3zcic2xyxrirlxpnzl4296h897648455"))))
83 (build-system python-build-system)
84 (native-inputs
85 `(("python-six" ,python-six)))
86 (home-page "https://github.com/d11wtq/dockerpty")
87 (synopsis "Python library to use the pseudo-TTY of a Docker container")
88 (description "Docker PTY provides the functionality needed to operate the
89 pseudo-terminal (PTY) allocated to a Docker container using the Python
90 client.")
91 (license license:asl2.0)))
92
93 (define-public docker-compose
94 (package
95 (name "docker-compose")
96 (version "1.5.2")
97 (source
98 (origin
99 (method url-fetch)
100 (uri (pypi-uri "docker-compose" version))
101 (sha256
102 (base32
103 "0ksg7hm2yvc977968dixxisrhcmvskzpcx3pz0v1kazrdqp7xakr"))))
104 (build-system python-build-system)
105 ;; TODO: Tests require running Docker daemon.
106 (arguments '(#:tests? #f))
107 (inputs
108 `(("python-docker-py" ,python-docker-py)
109 ("python-dockerpty" ,python-dockerpty)
110 ("python-docopt" ,python-docopt)
111 ("python-jsonschema" ,python-jsonschema)
112 ("python-pyyaml" ,python-pyyaml)
113 ("python-requests" ,python-requests-2.7)
114 ("python-six" ,python-six)
115 ("python-texttable" ,python-texttable)
116 ("python-websocket-client" ,python-websocket-client)))
117 (home-page "https://www.docker.com/")
118 (synopsis "Multi-container orchestration for Docker")
119 (description "Docker Compose is a tool for defining and running
120 multi-container Docker applications. A Compose file is used to configure an
121 application’s services. Then, using a single command, the containers are
122 created and all the services are started as specified in the configuration.")
123 (license license:asl2.0)))
124
125 (define-public python-docker-pycreds
126 (package
127 (name "python-docker-pycreds")
128 (version "0.3.0")
129 (source
130 (origin
131 (method url-fetch)
132 (uri (pypi-uri "docker-pycreds" version))
133 (sha256
134 (base32
135 "1zxvam1q22qb0jf48553nnncnfrcp88ag4xa0qmq6vr0imn9a3lb"))))
136 (build-system python-build-system)
137 (arguments
138 `(#:phases
139 (modify-phases %standard-phases
140 (add-after 'unpack 'fix-versioning
141 (lambda _
142 (substitute* "test-requirements.txt"
143 (("3.0.2") ,(package-version python-pytest))
144 (("2.3.1") ,(package-version python-pytest-cov))
145 (("2.4.1") ,(package-version python-flake8)))
146 #t)))))
147 (native-inputs
148 `(("python-flake8" ,python-flake8)
149 ("python-pytest" ,python-pytest)
150 ("python-pytest-cov" ,python-pytest-cov)))
151 (propagated-inputs
152 `(("python-six" ,python-six)))
153 (home-page "https://github.com/shin-/dockerpy-creds")
154 (synopsis
155 "Python bindings for the Docker credentials store API")
156 (description
157 "Docker-Pycreds contains the Python bindings for the docker credentials
158 store API. It allows programmers to interact with a Docker registry using
159 Python without keeping their credentials in a Docker configuration file.")
160 (license license:asl2.0)))
161
162 (define-public containerd
163 (package
164 (name "containerd")
165 (version "1.2.2")
166 (source
167 (origin
168 (method git-fetch)
169 (uri (git-reference
170 (url "https://github.com/containerd/containerd.git")
171 (commit (string-append "v" version))))
172 (file-name (git-file-name name version))
173 (sha256
174 (base32
175 "065snv0s3v3z0ghadlii4w78qnhchcbx2kfdrvm8fk8gb4pkx1ya"))))
176 (build-system go-build-system)
177 (arguments
178 `(#:import-path "github.com/containerd/containerd"
179 #:phases
180 (modify-phases %standard-phases
181 (add-before 'build 'chdir
182 (lambda _
183 (chdir "src/github.com/containerd/containerd")
184 #t))
185 (add-after 'chdir 'patch-paths
186 (lambda* (#:key inputs outputs #:allow-other-keys)
187 ;; TODO: Patch "socat", "unpigz".
188 (substitute* "./runtime/v1/linux/runtime.go"
189 (("defaultRuntime[ \t]*=.*")
190 (string-append "defaultRuntime = \""
191 (assoc-ref inputs "runc")
192 "/sbin/runc\"\n"))
193 (("defaultShim[ \t]*=.*")
194 (string-append "defaultShim = \""
195 (assoc-ref outputs "out")
196 "/bin/containerd-shim\"\n")))
197 (substitute* "./vendor/github.com/containerd/go-runc/runc.go"
198 (("DefaultCommand[ \t]*=.*")
199 (string-append "DefaultCommand = \""
200 (assoc-ref inputs "runc")
201 "/sbin/runc\"\n")))
202 (substitute* "vendor/github.com/containerd/continuity/testutil/loopback/loopback_linux.go"
203 (("exec\\.Command\\(\"losetup\"") ; )
204 (string-append "exec.Command(\""
205 (assoc-ref inputs "util-linux")
206 "/sbin/losetup\""))) ;)
207 #t))
208 (replace 'build
209 (lambda* (#:key (make-flags '()) #:allow-other-keys)
210 (apply invoke "make" make-flags)))
211 (replace 'install
212 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
213 (let* ((out (assoc-ref outputs "out")))
214 (apply invoke "make" (string-append "DESTDIR=" out) "install"
215 make-flags)))))))
216 (inputs
217 `(("btrfs-progs" ,btrfs-progs)
218 ("libseccomp" ,libseccomp)
219 ("runc" ,runc)
220 ("util-linux" ,util-linux)))
221 (native-inputs
222 `(("go" ,go)
223 ("pkg-config" ,pkg-config)))
224 (synopsis "Docker container runtime")
225 (description "This package provides the container daemon for Docker.
226 It includes image transfer and storage, container execution and supervision,
227 network attachments.")
228 (home-page "http://containerd.io/")
229 (license license:asl2.0)))
230
231 (define-public docker
232 (package
233 (name "docker")
234 (version %docker-version)
235 (source
236 (origin
237 (method git-fetch)
238 (uri (git-reference
239 (url "https://github.com/docker/engine.git")
240 (commit (string-append "v" version))))
241 (file-name (git-file-name name version))
242 (sha256
243 (base32
244 "1liqbx58grqih6m8hz9y20y5waflv19pv15l3wl64skap2bsn21c"))
245 (patches
246 (search-patches "docker-engine-test-noinstall.patch"
247 "docker-fix-tests.patch"))))
248 (build-system gnu-build-system)
249 (arguments
250 `(#:modules
251 ((guix build gnu-build-system)
252 ((guix build go-build-system) #:prefix go:)
253 (guix build utils))
254 #:imported-modules
255 (,@%gnu-build-system-modules
256 (guix build go-build-system))
257 #:phases
258 (modify-phases %standard-phases
259 (add-after 'unpack 'patch-paths
260 (lambda* (#:key inputs #:allow-other-keys)
261 (substitute* "builder/builder-next/executor_unix.go"
262 (("CommandCandidates:.*runc.*")
263 (string-append "CommandCandidates: []string{\""
264 (assoc-ref inputs "runc")
265 "/sbin/runc\"},\n")))
266 (substitute* "vendor/github.com/containerd/go-runc/runc.go"
267 (("DefaultCommand = .*")
268 (string-append "DefaultCommand = \""
269 (assoc-ref inputs "runc")
270 "/sbin/runc\"\n")))
271 (substitute* "vendor/github.com/containerd/containerd/runtime/v1/linux/runtime.go"
272 (("defaultRuntime[ \t]*=.*")
273 (string-append "defaultRuntime = \""
274 (assoc-ref inputs "runc")
275 "/sbin/runc\"\n"))
276 (("defaultShim[ \t]*=.*")
277 (string-append "defaultShim = \""
278 (assoc-ref inputs "containerd")
279 "/bin/containerd-shim\"\n")))
280 (substitute* "daemon/daemon_unix.go"
281 (("DefaultShimBinary = .*")
282 (string-append "DefaultShimBinary = \""
283 (assoc-ref inputs "containerd")
284 "/bin/containerd-shim\"\n"))
285 (("DefaultRuntimeBinary = .*")
286 (string-append "DefaultRuntimeBinary = \""
287 (assoc-ref inputs "runc")
288 "/sbin/runc\"\n"))
289 (("DefaultRuntimeName = .*")
290 (string-append "DefaultRuntimeName = \""
291 (assoc-ref inputs "runc")
292 "/sbin/runc\"\n")))
293 (substitute* "daemon/config/config.go"
294 (("StockRuntimeName = .*")
295 (string-append "StockRuntimeName = \""
296 (assoc-ref inputs "runc")
297 "/sbin/runc\"\n")))
298 (substitute* "vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go"
299 (("var defaultCommandCandidates = .*")
300 (string-append "var defaultCommandCandidates = []string{\""
301 (assoc-ref inputs "runc") "/sbin/runc\"}")))
302 (let ((source-files (filter (lambda (name)
303 (not (string-contains name "test")))
304 (find-files "." "\\.go$"))))
305 (let-syntax ((substitute-LookPath
306 (lambda (x)
307 (syntax-case x ()
308 ((substitute-LookPath source-text package
309 relative-path)
310 #`(substitute* source-files
311 ((#,(string-append "exec\\.LookPath\\(\""
312 (syntax->datum
313 #'source-text)
314 "\")"))
315 (string-append "\""
316 (assoc-ref inputs package)
317 relative-path
318 "\", error(nil)")))))))
319 (substitute-Command
320 (lambda (x)
321 (syntax-case x ()
322 ((substitute-LookPath source-text package
323 relative-path)
324 #`(substitute* source-files
325 ((#,(string-append "exec\\.Command\\(\""
326 (syntax->datum
327 #'source-text)
328 "\"")) ; )
329 (string-append "exec.Command(\""
330 (assoc-ref inputs package)
331 relative-path
332 "\"")))))))) ; )
333 (substitute-LookPath "ps" "procps" "/bin/ps")
334 (substitute-LookPath "mkfs.xfs" "xfsprogs" "/bin/mkfs.xfs")
335 (substitute-LookPath "lvmdiskscan" "lvm2" "/sbin/lvmdiskscan")
336 (substitute-LookPath "pvdisplay" "lvm2" "/sbin/pvdisplay")
337 (substitute-LookPath "blkid" "util-linux" "/sbin/blkid")
338 (substitute-LookPath "unpigz" "pigz" "/bin/unpigz")
339 (substitute-LookPath "iptables" "iptables" "/sbin/iptables")
340 (substitute-LookPath "ip" "iproute2" "/sbin/ip")
341 (substitute-Command "modprobe" "kmod" "/bin/modprobe")
342 (substitute-Command "pvcreate" "lvm2" "/sbin/pvcreate")
343 (substitute-Command "vgcreate" "lvm2" "/sbin/vgcreate")
344 (substitute-Command "lvcreate" "lvm2" "/sbin/lvcreate")
345 (substitute-Command "lvconvert" "lvm2" "/sbin/lvconvert")
346 (substitute-Command "lvchange" "lvm2" "/sbin/lvchange")
347 (substitute-Command "mkfs.xfs" "xfsprogs" "/sbin/mkfs.xfs")
348 (substitute-Command "xfs_growfs" "xfsprogs" "/sbin/xfs_growfs")
349 (substitute-Command "mkfs.ext4" "e2fsprogs" "/sbin/mkfs.ext4")
350 (substitute-Command "tune2fs" "e2fsprogs" "/sbin/tune2fs")
351 (substitute-Command "blkid" "util-linux" "/sbin/blkid")
352 (substitute-Command "resize2fs" "e2fsprogs" "/sbin/resize2fs")
353 ; docker-mountfrom ??
354 ; docker
355 ; docker-untar ??
356 ; docker-applyLayer ??
357 ; /usr/bin/uname
358 ; grep
359 ; apparmor_parser
360 (substitute-Command "ps" "procps" "/bin/ps")
361 (substitute-Command "losetup" "util-linux" "/sbin/losetup")
362 (substitute-Command "uname" "coreutils" "/bin/uname")
363 (substitute-Command "dbus-launch" "dbus" "/bin/dbus-launch")
364 (substitute-Command "git" "git" "/bin/git"))
365 ;; Make compilation fail when, in future versions, Docker
366 ;; invokes other programs we don't know about and thus don't
367 ;; substitute.
368 (substitute* source-files
369 ;; Search for Java in PATH.
370 (("\\<exec\\.Command\\(\"java\"") ; )
371 "xxec.Command(\"java\"") ; )
372 ;; Search for AUFS in PATH (mainline Linux doesn't support it).
373 (("\\<exec\\.Command\\(\"auplink\"") ; )
374 "xxec.Command(\"auplink\"") ; )
375 ;; Fail on other unsubstituted commands.
376 (("\\<exec\\.Command\\(\"([a-zA-Z0-9][a-zA-Z0-9_-]*)\""
377 _ executable) ; )
378 (string-append "exec.Guix_doesnt_want_Command(\""
379 executable "\"")) ;)
380 (("\\<xxec\\.Command")
381 "exec.Command")
382 ;; Search for ZFS in PATH.
383 (("\\<LookPath\\(\"zfs\"\\)") "LooxPath(\"zfs\")")
384 ;; Fail on other unsubstituted LookPaths.
385 (("\\<LookPath\\(\"") "Guix_doesnt_want_LookPath\\(\"") ; ))
386 (("\\<LooxPath") "LookPath")))
387 #t))
388 (add-after 'patch-paths 'delete-failing-tests
389 (lambda _
390 ;; Needs internet access.
391 (delete-file "builder/remotecontext/git/gitutils_test.go")
392 ;; Permission denied.
393 (delete-file "daemon/graphdriver/devmapper/devmapper_test.go")
394 ;; Operation not permitted (idtools.MkdirAllAndChown).
395 (delete-file "daemon/graphdriver/vfs/vfs_test.go")
396 ;; Timeouts after 5 min.
397 (delete-file "plugin/manager_linux_test.go")
398 ;; Operation not permitted.
399 (delete-file "daemon/graphdriver/overlay/overlay_test.go")
400 (delete-file "daemon/graphdriver/overlay2/overlay_test.go")
401 #t))
402 (replace 'configure
403 (lambda _
404 (setenv "DOCKER_GITCOMMIT" (string-append "v" ,%docker-version))
405 ;; Automatically use bundled dependencies.
406 ;; TODO: Unbundle - see file "vendor.conf".
407 (setenv "AUTO_GOPATH" "1")
408 ;; Respectively, strip the symbol table and debug
409 ;; information, and the DWARF symbol table.
410 (setenv "LDFLAGS" "-s -w")
411 ;; Make build faster
412 (setenv "GOCACHE" "/tmp")
413 #t))
414 (add-before 'build 'setup-environment
415 (assoc-ref go:%standard-phases 'setup-environment))
416 (replace 'build
417 (lambda _
418 ;; Our LD doesn't like the statically linked relocatable things
419 ;; that go produces, so install the dynamic version of
420 ;; dockerd instead.
421 (invoke "hack/make.sh" "dynbinary")))
422 (replace 'check
423 (lambda _
424 ;; The build process generated a file because the environment
425 ;; variable "AUTO_GOPATH" was set. Use it.
426 (setenv "GOPATH" (string-append (getcwd) "/.gopath"))
427 ;; ".gopath/src/github.com/docker/docker" is a link to the current
428 ;; directory and chdir would canonicalize to that.
429 ;; But go needs to have the uncanonicalized directory name, so
430 ;; store that.
431 (setenv "PWD" (string-append (getcwd)
432 "/.gopath/src/github.com/docker/docker"))
433 (with-directory-excursion ".gopath/src/github.com/docker/docker"
434 (invoke "hack/test/unit"))
435 (setenv "PWD" #f)
436 #t))
437 (replace 'install
438 (lambda* (#:key outputs #:allow-other-keys)
439 (let* ((out (assoc-ref outputs "out"))
440 (out-bin (string-append out "/bin")))
441 (install-file "bundles/dynbinary-daemon/dockerd" out-bin)
442 (install-file "bundles/dynbinary-daemon/dockerd-dev" out-bin)
443 #t))))))
444 (inputs
445 `(("btrfs-progs" ,btrfs-progs)
446 ("containerd" ,containerd) ; for containerd-shim
447 ("coreutils" ,coreutils)
448 ("dbus" ,dbus)
449 ("e2fsprogs" ,e2fsprogs)
450 ("git" ,git)
451 ("iproute2" ,iproute)
452 ("iptables" ,iptables)
453 ("kmod" ,kmod)
454 ("libseccomp" ,libseccomp)
455 ("pigz" ,pigz)
456 ("procps" ,procps)
457 ("runc" ,runc)
458 ("util-linux" ,util-linux)
459 ("lvm2" ,lvm2)
460 ("xfsprogs" ,xfsprogs)))
461 (native-inputs
462 `(("eudev" ,eudev) ; TODO: Should be propagated by lvm2 (.pc -> .pc)
463 ("go" ,go)
464 ("pkg-config" ,pkg-config)))
465 (synopsis "Docker container component library, and daemon")
466 (description "This package provides a framework to assemble specialized
467 container systems. It includes components for orchestration, image
468 management, secret management, configuration management, networking,
469 provisioning etc.")
470 (home-page "https://mobyproject.org/")
471 (license license:asl2.0)))
472
473 (define-public docker-cli
474 (package
475 (name "docker-cli")
476 (version %docker-version)
477 (source
478 (origin
479 (method git-fetch)
480 (uri (git-reference
481 (url "https://github.com/docker/cli.git")
482 (commit (string-append "v" version))))
483 (file-name (git-file-name name version))
484 (sha256
485 (base32
486 "1ivisys20kphvbqlazc3bsg7pk0ykj9gjx5d4yg439x4n13jxwvb"))))
487 (build-system go-build-system)
488 (arguments
489 `(#:import-path "github.com/docker/cli"
490 ;; TODO: Tests require a running Docker daemon.
491 #:tests? #f
492 #:phases
493 (modify-phases %standard-phases
494 (add-before 'build 'setup-environment-2
495 (lambda _
496 ;; Respectively, strip the symbol table and debug
497 ;; information, and the DWARF symbol table.
498 (setenv "LDFLAGS" "-s -w")
499
500 ;; Make build reproducible.
501 (setenv "BUILDTIME" "1970-01-01 00:00:01.000000000+00:00")
502 (symlink "src/github.com/docker/cli/scripts" "./scripts")
503 (symlink "src/github.com/docker/cli/docker.Makefile" "./docker.Makefile")
504 #t))
505 (replace 'build
506 (lambda _
507 (invoke "./scripts/build/dynbinary")))
508 (replace 'check
509 (lambda* (#:key make-flags tests? #:allow-other-keys)
510 (setenv "PATH" (string-append (getcwd) "/build:" (getenv "PATH")))
511 (if tests?
512 ;; Use the newly-built docker client for the tests.
513 (with-directory-excursion "src/github.com/docker/cli"
514 ;; TODO: Run test-e2e as well?
515 (apply invoke "make" "-f" "docker.Makefile" "test-unit"
516 (or make-flags '())))
517 #t)))
518 (replace 'install
519 (lambda* (#:key outputs #:allow-other-keys)
520 (let* ((out (assoc-ref outputs "out"))
521 (out-bin (string-append out "/bin")))
522 (chdir "build")
523 (install-file "docker" out-bin)
524 #t))))))
525 (native-inputs
526 `(("go" ,go)
527 ("libltdl" ,libltdl)
528 ("pkg-config" ,pkg-config)))
529 (synopsis "Command line interface to Docker")
530 (description "This package provides a command line interface to Docker.")
531 (home-page "https://www.docker.com/")
532 (license license:asl2.0)))
533
534 (define-public cqfd
535 (package
536 (name "cqfd")
537 (version "5.0.1")
538 (source (origin
539 (method git-fetch)
540 (uri (git-reference
541 (url "https://github.com/savoirfairelinux/cqfd.git")
542 (commit (string-append "v" version))))
543 (file-name (git-file-name name version))
544 (sha256
545 (base32
546 "1z4v16lbpbwd5ykawizdclpryp2k006lbk2mv427a4b3nvcd9wik"))))
547 (build-system gnu-build-system)
548 (arguments
549 ;; The test suite requires a docker daemon and connectivity.
550 `(#:tests? #f
551 #:phases
552 (modify-phases %standard-phases
553 (delete 'configure)
554 (delete 'build)
555 (replace 'install
556 (lambda* (#:key outputs #:allow-other-keys)
557 (let ((out (assoc-ref outputs "out")))
558 ;; Fix the directory of the bash completion.
559 (substitute* "Makefile"
560 (("completionsdir=.*$")
561 (string-append "completionsdir=" out
562 "/etc/bash_completion.d; \\\n")))
563 (invoke "make" "install"
564 (string-append "PREFIX=" out))))))))
565 (home-page "https://github.com/savoirfairelinux/cqfd")
566 (synopsis "Convenience wrapper for Docker")
567 (description "cqfd is a Bash script that provides a quick and convenient
568 way to run commands in the ecurrent directory, but within a Docker container
569 defined in a per-project configuration file.")
570 (license license:gpl3+)))