diff options
author | Vika <vika@fireburn.ru> | 2022-03-18 03:34:53 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2022-03-18 03:34:53 +0300 |
commit | 4c2a961474153218b0d3f65898df6e1c7bb12359 (patch) | |
tree | 3dfed909ea77a88e655cff8478be4d415553692d | |
parent | 95ce885dbc1f8c5c431c7607a054d08da7392867 (diff) | |
download | kittybox-4c2a961474153218b0d3f65898df6e1c7bb12359.tar.zst |
Added a docker container image built from Nix
This is so minimal it can't be much less than this. Use it with `docker load`.
-rw-r--r-- | flake.nix | 45 |
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 { |