From 4c2a961474153218b0d3f65898df6e1c7bb12359 Mon Sep 17 00:00:00 2001 From: Vika Date: Fri, 18 Mar 2022 03:34:53 +0300 Subject: 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`. --- flake.nix | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'flake.nix') 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 { -- cgit 1.4.1