Allow for changing port #s

This commit is contained in:
niten 2023-07-22 14:19:00 -07:00
parent 6cf055b0e6
commit d7b2bd21ab
1 changed files with 17 additions and 4 deletions

View File

@ -13,8 +13,9 @@ let
in pkgs.writeText "envFile" (concatStringsSep "\n" envLines); in pkgs.writeText "envFile" (concatStringsSep "\n" envLines);
makeTeslaMateImage = { teslaMateImage, postgresImage, grafanaImage makeTeslaMateImage = { teslaMateImage, postgresImage, grafanaImage
, teslaMateEnvFile, postgresEnvFile, grafanaEnvFile, teslaMateUid , teslaMatePort, grafanaPort, teslaMateEnvFile, postgresEnvFile
, postgresUid, grafanaUid, stateDirectory, ... }: , grafanaEnvFile, teslaMateUid, postgresUid, grafanaUid, stateDirectory, ...
}:
{ pkgs, ... }: { { pkgs, ... }: {
project.name = "teslamate"; project.name = "teslamate";
services = { services = {
@ -23,7 +24,7 @@ let
image = teslaMateImage; image = teslaMateImage;
restart = "always"; restart = "always";
volumes = [ "${stateDirectory}/import:/opt/app/import" ]; volumes = [ "${stateDirectory}/import:/opt/app/import" ];
ports = [ "4000:4000" ]; ports = [ "${toString teslaMatePort}:4000" ];
user = "${toString teslaMateUid}:${toString teslaMateUid}"; user = "${toString teslaMateUid}:${toString teslaMateUid}";
env_file = [ teslaMateEnvFile ]; env_file = [ teslaMateEnvFile ];
capabilities.ALL = false; capabilities.ALL = false;
@ -45,7 +46,7 @@ let
volumes = [ "${stateDirectory}/grafana:/var/lib/grafana" ]; volumes = [ "${stateDirectory}/grafana:/var/lib/grafana" ];
env_file = [ grafanaEnvFile ]; env_file = [ grafanaEnvFile ];
user = "${toString grafanaUid}:${toString grafanaUid}"; user = "${toString grafanaUid}:${toString grafanaUid}";
ports = [ "3000:3000" ]; ports = [ "${toString grafanaPort}:3000" ];
}; };
}; };
}; };
@ -94,6 +95,16 @@ in {
}; };
}; };
port = mkOption {
type = port;
description = "Local port on which to listen for TeslaMate requests.";
};
grafana-port = mkOption {
type = port;
description = "Local port on which to listen for Grafana requests.";
};
state-directory = mkOption { state-directory = mkOption {
type = str; type = str;
description = "Path at which to store service state."; description = "Path at which to store service state.";
@ -164,6 +175,8 @@ in {
teslaMateImage = cfg.images.tesla-mate; teslaMateImage = cfg.images.tesla-mate;
postgresImage = cfg.images.postgres; postgresImage = cfg.images.postgres;
grafanaImage = cfg.images.grafana; grafanaImage = cfg.images.grafana;
teslaMatePort = cfg.port;
grafanaPort = cfg.grafana-port;
stateDirectory = cfg.state-directory; stateDirectory = cfg.state-directory;
teslaMateEnvFile = hostSecrets.teslaMateEnv.target-file; teslaMateEnvFile = hostSecrets.teslaMateEnv.target-file;
postgresEnvFile = hostSecrets.teslaMatePostgresEnv.target-file; postgresEnvFile = hostSecrets.teslaMatePostgresEnv.target-file;