about summary refs log tree commit diff
path: root/docker.nix
blob: 2ac09b632b943a1f85758bd90754833b758d09c0 (plain) (blame)
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
{ kittybox, dockerTools, runtimeShell, rev ? "development", lastModifiedDate }:
dockerTools.buildImage {
  name = "kittybox";
  tag = rev;
  created = let
    date = lastModifiedDate;
  in builtins.concatStringsSep "" [
    (builtins.substring 0 4 date)
    "-"
    (builtins.substring 4 2 date)
    "-"
    (builtins.substring 6 2 date)
    "T"
    (builtins.substring 8 2 date)
    ":"
    (builtins.substring 10 2 date)
    ":"
    (builtins.substring 12 2 date)
    "Z"
  ];

  runAsRoot = ''
    #!${runtimeShell}
    ${dockerTools.shadowSetup}
    groupadd -r kittybox
    useradd -r -g kittybox kittybox
    mkdir -p /data
    chown kittybox:kittybox /data
  '';

  config = {
    Cmd = [ "${kittybox}/bin/kittybox" ];
    Env = [
      "SERVE_AT=0.0.0.0:8080"
      "BACKEND_URI=file:///data"
      "RUST_LOG=info"
    ];
    WorkingDir = "/data";
    Volumes = { "/data" = {}; };
    User = "kittybox";
    ExposedPorts = { "8080" = {}; };
  };
}