git.iko.soy/typeable/nixpkgs
on master help sign in
docker: 19.03.4 -> 20.10.2 (#108960)

This commit refactors the build process to handle Docker engine and CLI split.

commitb451286b1f56a65ad37fb606b7a77e73b10911e5 authorMark Vainomaa <mikroskeem@mikroskeem.eu> dateWed 13 Jan 2021, 12:33 (6 years ago) parente6a184a
3 files changed+96−99
nixos/modules/virtualisation/docker.nix+2−4 pkgs/applications/virtualization/docker/default.nix+91−91 pkgs/top-level/all-packages.nix+3−4
nixos/modules/virtualisation/docker.nix+2−4
@@ -155,19 +155,17 @@ in
155155 users.groups.docker.gid = config.ids.gids.docker;
156156 systemd.packages = [ cfg.package ];
157157
158− # TODO: remove once docker 20.10 is released
159− systemd.enableUnifiedCgroupHierarchy = false;
160−
161158 systemd.services.docker = {
162159 wantedBy = optional cfg.enableOnBoot "multi-user.target";
163160 environment = proxy_env;
164161 serviceConfig = {
162+ Type = "notify";
165163 ExecStart = [
166164 ""
167165 ''
168166 ${cfg.package}/bin/dockerd \
169167 --group=docker \
170− --host=fd:// \
168+ --host=unix:// \
171169 --log-driver=${cfg.logDriver} \
172170 ${optionalString (cfg.storageDriver != null) "--storage-driver=${cfg.storageDriver}"} \
173171 ${optionalString cfg.liveRestore "--live-restore" } \
pkgs/applications/virtualization/docker/default.nix+91−91
@@ -1,5 +1,5 @@
11{ stdenv, lib, fetchFromGitHub, fetchpatch, buildGoPackage
2−, makeWrapper, installShellFiles, pkgconfig
2+, makeWrapper, installShellFiles, pkg-config
33, go-md2man, go, containerd, runc, docker-proxy, tini, libtool
44, sqlite, iproute, lvm2, systemd
55, btrfs-progs, iptables, e2fsprogs, xz, util-linux, xfsprogs, git
@@ -12,6 +12,7 @@ with lib;
1212rec {
1313 dockerGen = {
1414 version, rev, sha256
15+ , mobyRev, mobySha256
1516 , runcRev, runcSha256
1617 , containerdRev, containerdSha256
1718 , tiniRev, tiniSha256
@@ -30,9 +31,7 @@ rec {
3031 patches = [];
3132 });
3233
33− docker-containerd = let
34− withlibseccomp = lib.versionAtLeast version "19.03";
35− in containerd.overrideAttrs (oldAttrs: {
34+ docker-containerd = containerd.overrideAttrs (oldAttrs: {
3635 name = "docker-containerd-${version}";
3736 inherit version;
3837 src = fetchFromGitHub {
@@ -41,11 +40,7 @@ rec {
4140 rev = containerdRev;
4241 sha256 = containerdSha256;
4342 };
44− # disable completion, can be removed when docker uses containerd >= 1.4
45− postInstall = [];
46− # This should be removed once Docker uses containerd >=1.4
47− nativeBuildInputs = oldAttrs.nativeBuildInputs ++ lib.optional withlibseccomp pkgconfig;
48− buildInputs = oldAttrs.buildInputs ++ lib.optional withlibseccomp libseccomp;
43+ buildInputs = oldAttrs.buildInputs ++ [ libseccomp ];
4944 });
5045
5146 docker-tini = tini.overrideAttrs (oldAttrs: {
@@ -64,16 +59,69 @@ rec {
6459
6560 NIX_CFLAGS_COMPILE = "-DMINIMAL=ON";
6661 });
62+
63+ moby = buildGoPackage ((optionalAttrs (stdenv.isLinux)) rec {
64+ name = "moby-${version}";
65+ inherit version;
66+ inherit docker-runc docker-containerd docker-proxy docker-tini;
67+
68+ src = fetchFromGitHub {
69+ owner = "moby";
70+ repo = "moby";
71+ rev = mobyRev;
72+ sha256 = mobySha256;
73+ };
74+
75+ goPackagePath = "github.com/docker/docker";
76+
77+ nativeBuildInputs = [ makeWrapper pkg-config go-md2man go libtool installShellFiles ];
78+ buildInputs = [ sqlite lvm2 btrfs-progs systemd libseccomp ];
79+
80+ extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps util-linux git ]);
81+
82+ buildPhase = ''
83+ export GOCACHE="$TMPDIR/go-cache"
84+ # build engine
85+ cd ./go/src/${goPackagePath}
86+ export AUTO_GOPATH=1
87+ export DOCKER_GITCOMMIT="${rev}"
88+ export VERSION="${version}"
89+ ./hack/make.sh dynbinary
90+ cd -
91+ '';
92+
93+ postPatch = ''
94+ patchShebangs .
95+ substituteInPlace ./hack/make.sh --replace libsystemd-journal libsystemd
96+ '';
97+
98+ installPhase = ''
99+ cd ./go/src/${goPackagePath}
100+ install -Dm755 ./bundles/dynbinary-daemon/dockerd $out/libexec/docker/dockerd
101+
102+ makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \
103+ --prefix PATH : "$out/libexec/docker:$extraPath"
104+
105+ ln -s ${docker-containerd}/bin/containerd $out/libexec/docker/containerd
106+ ln -s ${docker-containerd}/bin/containerd-shim $out/libexec/docker/containerd-shim
107+ ln -s ${docker-runc}/bin/runc $out/libexec/docker/runc
108+ ln -s ${docker-proxy}/bin/docker-proxy $out/libexec/docker/docker-proxy
109+ ln -s ${docker-tini}/bin/tini-static $out/libexec/docker/docker-init
110+
111+ # systemd
112+ install -Dm644 ./contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service
113+ '';
114+
115+ DOCKER_BUILDTAGS = []
116+ ++ optional (systemd != null) [ "journald" ]
117+ ++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs"
118+ ++ optional (lvm2 == null) "exclude_graphdriver_devicemapper"
119+ ++ optional (libseccomp != null) "seccomp";
120+ });
67121 in
68122 buildGoPackage ((optionalAttrs (stdenv.isLinux) {
69123
70− inherit docker-runc docker-containerd docker-proxy docker-tini;
71−
72− DOCKER_BUILDTAGS = []
73− ++ optional (systemd != null) [ "journald" ]
74− ++ optional (btrfs-progs == null) "exclude_graphdriver_btrfs"
75− ++ optional (lvm2 == null) "exclude_graphdriver_devicemapper"
76− ++ optional (libseccomp != null) "seccomp";
124+ inherit docker-runc docker-containerd docker-proxy docker-tini moby;
77125
78126 }) // rec {
79127 inherit version rev;
@@ -82,97 +130,61 @@ rec {
82130
83131 src = fetchFromGitHub {
84132 owner = "docker";
85− repo = "docker-ce";
133+ repo = "cli";
86134 rev = "v${version}";
87135 sha256 = sha256;
88136 };
89137
90− patches = lib.optional (versionAtLeast version "19.03") [
91− # Replace hard-coded cross-compiler with $CC
92− (fetchpatch {
93− url = https://github.com/docker/docker-ce/commit/2fdfb4404ab811cb00227a3de111437b829e55cf.patch;
94− sha256 = "1af20bzakhpfhaixc29qnl9iml9255xdinxdnaqp4an0n1xa686a";
95− })
96− ];
97−
98− goPackagePath = "github.com/docker/docker-ce";
138+ goPackagePath = "github.com/docker/cli";
99139
100− nativeBuildInputs = [ pkgconfig go-md2man go libtool installShellFiles ];
140+ nativeBuildInputs = [ pkg-config go-md2man go libtool installShellFiles ];
101141 buildInputs = [
102142 makeWrapper
103143 ] ++ optionals (stdenv.isLinux) [
104144 sqlite lvm2 btrfs-progs systemd libseccomp
105145 ];
106146
107− dontStrip = true;
108−
147+ # Keep eyes on BUILDTIME format - https://github.com/docker/cli/blob/${version}/scripts/build/.variables
109148 buildPhase = ''
110149 export GOCACHE="$TMPDIR/go-cache"
111− '' + (optionalString (stdenv.isLinux) ''
112− # build engine
113− cd ./go/src/${goPackagePath}/components/engine
114− export AUTO_GOPATH=1
115− export DOCKER_GITCOMMIT="${rev}"
116− export VERSION="${version}"
117− ./hack/make.sh dynbinary
118− cd -
119− '') + ''
120− # build cli
121− cd ./go/src/${goPackagePath}/components/cli
150+
151+ cd ./go/src/${goPackagePath}
122152 # Mimic AUTO_GOPATH
123153 mkdir -p .gopath/src/github.com/docker/
124154 ln -sf $PWD .gopath/src/github.com/docker/cli
125155 export GOPATH="$PWD/.gopath:$GOPATH"
126156 export GITCOMMIT="${rev}"
127157 export VERSION="${version}"
158+ export BUILDTIME="1970-01-01T00:00:00Z"
128159 source ./scripts/build/.variables
129160 export CGO_ENABLED=1
130161 go build -tags pkcs11 --ldflags "$LDFLAGS" github.com/docker/cli/cmd/docker
131162 cd -
132163 '';
133164
134− # systemd 230 no longer has libsystemd-journal as a separate entity from libsystemd
135165 postPatch = ''
136− substituteInPlace ./components/cli/scripts/build/.variables --replace "set -eu" ""
137− '' + optionalString (stdenv.isLinux) ''
138166 patchShebangs .
139− substituteInPlace ./components/engine/hack/make.sh --replace libsystemd-journal libsystemd
140− substituteInPlace ./components/engine/daemon/logger/journald/read.go --replace libsystemd-journal libsystemd
167+ substituteInPlace ./scripts/build/.variables --replace "set -eu" ""
168+ substituteInPlace ./scripts/docs/generate-man.sh --replace "-v md2man" "-v go-md2man"
169+ substituteInPlace ./man/md2man-all.sh --replace md2man go-md2man
141170 '';
142171
143172 outputs = ["out" "man"];
144173
145− extraPath = optionals (stdenv.isLinux) (makeBinPath [ iproute iptables e2fsprogs xz xfsprogs procps util-linux git ]);
146−
147174 installPhase = ''
148175 cd ./go/src/${goPackagePath}
149− install -Dm755 ./components/cli/docker $out/libexec/docker/docker
176+ install -Dm755 ./docker $out/libexec/docker/docker
150177
151178 makeWrapper $out/libexec/docker/docker $out/bin/docker \
152179 --prefix PATH : "$out/libexec/docker:$extraPath"
153180 '' + optionalString (stdenv.isLinux) ''
154− install -Dm755 ./components/engine/bundles/dynbinary-daemon/dockerd $out/libexec/docker/dockerd
155−
156− makeWrapper $out/libexec/docker/dockerd $out/bin/dockerd \
157− --prefix PATH : "$out/libexec/docker:$extraPath"
158−
159− # docker uses containerd now
160− ln -s ${docker-containerd}/bin/containerd $out/libexec/docker/containerd
161− ln -s ${docker-containerd}/bin/containerd-shim $out/libexec/docker/containerd-shim
162− ln -s ${docker-runc}/bin/runc $out/libexec/docker/runc
163− ln -s ${docker-proxy}/bin/docker-proxy $out/libexec/docker/docker-proxy
164− ln -s ${docker-tini}/bin/tini-static $out/libexec/docker/docker-init
165−
166− # systemd
167− install -Dm644 ./components/engine/contrib/init/systemd/docker.service $out/etc/systemd/system/docker.service
181+ # symlink docker daemon to docker cli derivation
182+ ln -s ${moby}/bin/dockerd $out/bin/dockerd
168183 '' + ''
169184 # completion (cli)
170− installShellCompletion --bash ./components/cli/contrib/completion/bash/docker
171− installShellCompletion --fish ./components/cli/contrib/completion/fish/docker.fish
172− installShellCompletion --zsh ./components/cli/contrib/completion/zsh/_docker
173−
174− # Include contributed man pages (cli)
175− cd ./components/cli
185+ installShellCompletion --bash ./contrib/completion/bash/docker
186+ installShellCompletion --fish ./contrib/completion/fish/docker.fish
187+ installShellCompletion --zsh ./contrib/completion/zsh/_docker
176188 '' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
177189 # Generate man pages from cobra commands
178190 echo "Generate man pages from cobra"
@@ -199,30 +211,18 @@ rec {
199211 });
200212
201213 # Get revisions from
202− # https://github.com/docker/docker-ce/tree/${version}/components/engine/hack/dockerfile/install/*
203−
204− docker_18_09 = makeOverridable dockerGen rec {
205− version = "18.09.9";
206− rev = "v${version}";
207− sha256 = "0wqhjx9qs96q2jd091wffn3cyv2aslqn2cvpdpgljk8yr9s0yg7h";
208− runcRev = "3e425f80a8c931f88e6d94a8c831b9d5aa481657";
209− runcSha256 = "18psc830b2rkwml1x6vxngam5b5wi3pj14mw817rshpzy87prspj";
210− containerdRev = "894b81a4b802e4eb2a91d1ce216b8817763c29fb";
211− containerdSha256 = "0sp5mn5wd3xma4svm6hf67hyhiixzkzz6ijhyjkwdrc4alk81357";
212− tiniRev = "fec3683b971d9c3ef73f284f176672c44b448662";
213− tiniSha256 = "1h20i3wwlbd8x4jr2gz68hgklh0lb0jj7y5xk1wvr8y58fip1rdn";
214− };
215−
216− docker_19_03 = makeOverridable dockerGen rec {
217− version = "19.03.14";
214+ # https://github.com/moby/moby/tree/${version}/hack/dockerfile/install/*
215+ docker_20_10 = makeOverridable dockerGen rec {
216+ version = "20.10.2";
218217 rev = "v${version}";
219− sha256 = "0szr5dgfrypb5kyj5l1rf7rw4iqj0d0cyx6skdqlbgf4dqwa6g9y";
220− runcRev = "dc9208a3303feef5b3839f4323d9beb36df0a9dd"; # v1.0.0-rc10
221− runcSha256 = "0pi3rvj585997m4z9ljkxz2z9yxf9p2jr0pmqbqrc7bc95f5hagk";
222− # Note: Once all packaged Docker versions use containerd <=1.2 or >=1.4 remove the libseccomp and pkgconfig inputs above
223− containerdRev = "ea765aba0d05254012b0b9e595e995c09186427f"; # v1.3.9
224− containerdSha256 = "1isi1wgq61b4l0lxy1d8n6dnmcb8s5ihn2yqjb6525y3dj5c5i1j";
225− tiniRev = "fec3683b971d9c3ef73f284f176672c44b448662"; # v0.18.0
218+ sha256 = "0z0hpm5hrqh7p8my8lmiwpym2shs48my6p0zv2cc34wym0hcly51";
219+ mobyRev = "v${version}";
220+ mobySha256 = "0c2zycpnwj4kh8m8xckv1raj3fx07q9bfaj46rr85jihm4p2dp5w";
221+ runcRev = "ff819c7e9184c13b7c2607fe6c30ae19403a7aff"; # v1.0.0-rc92
222+ runcSha256 = "0r4zbxbs03xr639r7848282j1ybhibfdhnxyap9p76j5w8ixms94";
223+ containerdRev = "269548fa27e0089a8b8278fc4fc781d7f65a939b"; # v1.4.3
224+ containerdSha256 = "09xvhjg5f8h90w1y94kqqnqzhbhd62dcdd9wb9sdqakisjk6zrl0";
225+ tiniRev = "de40ad007797e0dcd8b7126f27bb87401d224240"; # v0.19.0
226226 tiniSha256 = "1h20i3wwlbd8x4jr2gz68hgklh0lb0jj7y5xk1wvr8y58fip1rdn";
227227 };
228228}
pkgs/top-level/all-packages.nix+3−4
@@ -21302,11 +21302,10 @@ in
2130221302 };
2130321303
2130421304 inherit (callPackage ../applications/virtualization/docker {})
21305− docker_18_09
21306− docker_19_03;
21305+ docker_20_10;
2130721306
21308− docker = docker_19_03;
21309− docker-edge = docker_19_03;
21307+ docker = docker_20_10;
21308+ docker-edge = docker_20_10;
2131021309
2131121310 docker-proxy = callPackage ../applications/virtualization/docker/proxy.nix { };
2131221311