about summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix45
1 files changed, 43 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix
index 2e1966b..648622a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -254,8 +254,49 @@
               # Testing for a known string is the easiest way to determine that the onboarding worked
               kittybox.succeed("curl --silent http://localhost:8080/ | grep 'vestige of the past long gone'")
         '';
-      }))
-      ;
+      }));
+      dockerContainer = pkgs.dockerTools.buildImage {
+        name = "kittybox";
+        tag = self.rev or "development";
+        created = let
+          date = self.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 = ''
+          #!${pkgs.runtimeShell}
+          ${pkgs.dockerTools.shadowSetup}
+          groupadd -r kittybox
+          useradd -r -g kittybox kittybox
+          mkdir -p /data
+          chown kittybox:kittybox /data
+        '';
+
+        config = {
+          Cmd = [ "${self.packages.${system}.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" = {}; };
+        };
+      };
     };
 
     devShell = pkgs.mkShell {