{ config, containerCfg, pkgs, lib, builder, name,... }:
let 
  serverCfg = config.syscfg.server;
  ethercalc_exe = pkgs.ethercalc;

  image = pkgs.dockerTools.streamLayeredImage {
    name = "ethercalc";
    tag = ethercalc_exe.version;
    contents = [ pkgs.bashInteractive ];
    config = {
      Entrypoint = [ "${ethercalc_exe}/bin/ethercalc" ];
      ExposedPorts = { "8080/tcp" = {}; };
    };
  };
in {
  requires.secrets = [ name ];

  runtime = {
    paths = [{
      path="${serverCfg.path.data.path}/ethercalc/";
      mode = "0666";
    }];

    containers = {
      server = builder.mkContainer {
        subdomain = containerCfg.subdomain;
        imageStream = image;
        port = 8080;
        secret = name;
        extraEnv = {
          ETHERCALC_PORT = "8080";
          #CONNECT TO REDIS
        };
        overrides = {
          volumes = [
            "${serverCfg.path.data.path}/ethercalc:/data"
          ];
         };
      };
    };
  };
}
