-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.nix
40 lines (36 loc) · 834 Bytes
/
docker.nix
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
{ nixpkgs, pkgs, lib, ... }:
let
repeat = n: a: accum:
if n == 0 then accum else repeat (n - 1) a (accum ++ [ a ]);
r = n: a: repeat n a [ ];
in
(
{ cont
, name ? cont.name
, tag
, cmd ? [ ]
, workDir ? "/data"
, enableLocale ? false
, extraDockerConfig ? { }
, env ? [ ]
, maxLayers ? 120
, perLayer ? 3
, hints ? r (maxLayers - 1) perLayer
}:
let
dockerTools = pkgs.callPackage (./dockertools/default.nix) { };
in
dockerTools.buildLayeredImage {
inherit maxLayers name tag hints;
contents = pkgs.symlinkJoin {
name = "${name}-contents";
paths = [ cont.sys.build.etc cont.sys.path ] ++ cont.contents;
};
config = {
Entrypoint = cont.entrypoint;
Cmd = cmd;
WorkingDir = workDir;
Env = cont.env ++ env;
} // extraDockerConfig;
}
)