diff --git a/docker/headless/docker-compose.yaml b/docker/headless/docker-compose.yaml index 3b00ee9fe..2326c0fd4 100644 --- a/docker/headless/docker-compose.yaml +++ b/docker/headless/docker-compose.yaml @@ -6,6 +6,7 @@ services: image: philosowaffle/peloton-to-garmin:console-stable environment: - TZ=America/Chicago + - P2G_CONFIG_DIRECTORY=/app/config volumes: - - ./configuration.local.json:/app/configuration.local.json + - ./config:/app/config - ./output:/app/output diff --git a/docker/webui/docker-compose-ui.yaml b/docker/webui/docker-compose-ui.yaml index 074b2f88a..6912cec2d 100644 --- a/docker/webui/docker-compose-ui.yaml +++ b/docker/webui/docker-compose-ui.yaml @@ -6,10 +6,11 @@ services: image: philosowaffle/peloton-to-garmin:api-stable environment: - TZ=America/Chicago + - P2G_CONFIG_DIRECTORY=/app/config # ports: # - 8001:8080 # optional, only if you plan to interact with the API directly volumes: - - ./api.local.json:/app/configuration.local.json + - ./config/api/:/app/config - ./data:/app/data # recommended for saving settings across restarts - ./output:/app/output # optional, if you want access to the generated workout and log files @@ -20,7 +21,8 @@ services: - 8002:8080 environment: - TZ=America/Chicago + - P2G_CONFIG_DIRECTORY=/app/config volumes: - - ./webui.local.json:/app/configuration.local.json + - ./config/webui:/app/config depends_on: - p2g-api diff --git a/mkdocs/docs/configuration/index.md b/mkdocs/docs/configuration/index.md index 609e5867a..8f6c1f2a4 100644 --- a/mkdocs/docs/configuration/index.md +++ b/mkdocs/docs/configuration/index.md @@ -68,6 +68,9 @@ P2G supports configuration via By default, P2G looks for a file named `configuration.local.json` in the same directory where it is run. +!!! tip + You can override where the config Directory is mounted in the docker container by setting the environment vairable `P2G_CONFIG_DIRECTORY`. P2G will expect to find a `configuration.local.json` file in the specified directory. + ### Config Precedence The following defines the precedence in which config definitions are honored. With the first items having higher precendence than the next items. @@ -121,3 +124,10 @@ For nested config sections, continue to use the same naming convention of defini ```bash P2G_OBSERVABILITY__SERILOG__WRITETO__0__NAME="File" ``` +#### Additional Environment Variables + +In addition to overriding config values, the following extra environment variables are also supported. + +| ENV Variable | Required | Default | Description | +|:-------------|:---------|:--------|:--------------------------| +| `P2G_CONFIG_DIRECTORY` | false | P2G Directory | Tells P2G where to look for the `configuration.local.json` file | \ No newline at end of file diff --git a/mkdocs/docs/install/docker-headless.md b/mkdocs/docs/install/docker-headless.md index c75a896ed..24f0c9800 100644 --- a/mkdocs/docs/install/docker-headless.md +++ b/mkdocs/docs/install/docker-headless.md @@ -22,7 +22,8 @@ This flavor of P2G runs without any user interface and relies on configuration f 1. Create a directory `p2g-headless` 1. Inside this folder create a [docker-compose.yaml](https://github.com/philosowaffle/peloton-to-garmin/blob/master/docker/headless/docker-compose.yaml) file in the directory - 1. Also create a [configuration.local.json](https://github.com/philosowaffle/peloton-to-garmin/blob/master/configuration.example.json) file in the directory. + 1. Within this same directory, also create a folder called `config` + 1. Inside the `config` folder create the [configuration.local.json](https://github.com/philosowaffle/peloton-to-garmin/blob/master/configuration.example.json). 1. Edit the configuration file to use your Peloton and Garmin credentials 1. Open a terminal in this folder 1. Run: `docker-compose pull && docker-compose up -d` diff --git a/mkdocs/docs/install/docker-webui.md b/mkdocs/docs/install/docker-webui.md index d40149823..a5ba1385c 100644 --- a/mkdocs/docs/install/docker-webui.md +++ b/mkdocs/docs/install/docker-webui.md @@ -16,9 +16,11 @@ P2G provides a website user interface. Some key features include: 1. Create a folder named `p2g-webui` 1. Inside this folder create [docker-compose.yaml](https://github.com/philosowaffle/peloton-to-garmin/blob/master/docker/webui/docker-compose-ui.yaml) - 1. Also create [api.local.json](https://github.com/philosowaffle/peloton-to-garmin/blob/master/docker/webui/api.local.json) - 1. Also create [webui.local.json](https://github.com/philosowaffle/peloton-to-garmin/blob/master/docker/webui/webui.local.json) -1. Open a terminal in this folder + 1. Within this same directory, also create a folder called `config` + 1. Create two more folders within the `config` directory: `api` and `webui` + 1. Within the `api` folder, create [api.local.json](https://github.com/philosowaffle/peloton-to-garmin/blob/master/docker/webui/api.local.json) + 1. Within the `webui` folder, create [webui.local.json](https://github.com/philosowaffle/peloton-to-garmin/blob/master/docker/webui/webui.local.json) +1. Open a terminal in the `p2g-webui` folder 1. Run: `docker-compose pull && docker-compose up -d` 1. This will pull the containers and start them up running in the background 1. You can close the terminal at this time @@ -43,33 +45,4 @@ If you are migrating to the Web UI for the first time you will need to reconfigu ## Open Api -To access the Open API spec for P2G you will need to expose the below port on the Api docker container. The open API spec will be available at `http://localhost:8001/swagger`. - -```yaml -version: "3.9" - -services: - p2g-api: - container_name: p2g-api - image: philosowaffle/peloton-to-garmin:api-stable - environment: - - TZ=America/Chicago - ports: - - 8001:8080 # to access the api or swagger docs - volumes: - - ./api.local.json:/app/configuration.local.json - - ./data:/app/data - - ./output:/app/output - - p2g-webui: - container_name: p2g-webui - image: philosowaffle/peloton-to-garmin:webui-stable - ports: - - 8002:8080 - environment: - - TZ=America/Chicago - volumes: - - ./webui.local.json:/app/configuration.local.json - depends_on: - - p2g-api -``` +To access the Open API spec for P2G you will need to expose port `8080` on the Api docker container. The open API spec will be available at `http://localhost:8001/swagger`. diff --git a/src/Api/Program.cs b/src/Api/Program.cs index 41e1f93c6..d7ba560c8 100644 --- a/src/Api/Program.cs +++ b/src/Api/Program.cs @@ -14,7 +14,7 @@ Statics.AppType = Constants.ApiName; Statics.MetricPrefix = Constants.ApiName; Statics.TracingService = Constants.ApiName; -Statics.ConfigPath = Path.Join(Environment.CurrentDirectory, "configuration.local.json"); +Statics.ConfigPath = Path.Join(Statics.DefaultConfigDirectory, "configuration.local.json"); /////////////////////////////////////////////////////////// /// HOST @@ -22,7 +22,7 @@ var builder = WebApplication.CreateBuilder(args); var configProvider = builder.Configuration.AddJsonFile(Statics.ConfigPath, optional: true, reloadOnChange: true) - .AddEnvironmentVariables(prefix: "P2G_") + .AddEnvironmentVariables(prefix: $"{Constants.EnvironmentVariablePrefix}_") .AddCommandLine(args); var config = new AppConfiguration(); diff --git a/src/ClientUI/MauiProgram.cs b/src/ClientUI/MauiProgram.cs index deb9dac86..17239ec99 100644 --- a/src/ClientUI/MauiProgram.cs +++ b/src/ClientUI/MauiProgram.cs @@ -18,7 +18,7 @@ public static MauiApp CreateMauiApp() Statics.AppType = Constants.ClientUIName; Statics.MetricPrefix = Constants.ClientUIName; Statics.TracingService = Constants.ClientUIName; - Statics.ConfigPath = Path.Join(Environment.CurrentDirectory, "configuration.local.json"); + Statics.ConfigPath = Path.Join(Statics.DefaultConfigDirectory, "configuration.local.json"); Directory.CreateDirectory(Statics.DefaultOutputDirectory); @@ -38,7 +38,7 @@ public static MauiApp CreateMauiApp() InitObservabilityConfigFile("configuration.local.json", observabilityConfigFilePath); var configProvider = builder.Configuration.AddJsonFile(observabilityConfigFilePath, optional: true, reloadOnChange: true) - .AddEnvironmentVariables(prefix: "P2G_"); + .AddEnvironmentVariables(prefix: $"{Constants.EnvironmentVariablePrefix}_"); var config = new AppConfiguration(); ConfigurationSetup.LoadConfigValues(builder.Configuration, config); diff --git a/src/Common/Constants.cs b/src/Common/Constants.cs index 715262e19..c140aefaf 100644 --- a/src/Common/Constants.cs +++ b/src/Common/Constants.cs @@ -9,6 +9,6 @@ public static class Constants public const string WebUIName = "p2g_webui"; public const string ClientUIName = "p2g_clientui"; - public const string AppVersion = "4.3.1"; + public const string AppVersion = "4.4.0-rc"; } } diff --git a/src/Common/Dto/Settings.cs b/src/Common/Dto/Settings.cs index 6d2beffb2..5463ad617 100644 --- a/src/Common/Dto/Settings.cs +++ b/src/Common/Dto/Settings.cs @@ -39,7 +39,7 @@ public App() public int PollingIntervalSeconds { get; set; } public bool CheckForUpdates { get; set; } - public static string DataDirectory => Path.GetFullPath(Path.Join(Statics.DefaultDataDirectory, "data")); + public static string DataDirectory => Statics.DefaultDataDirectory; public string WorkingDirectory => Statics.DefaultTempDirectory; public string OutputDirectory => Statics.DefaultOutputDirectory; diff --git a/src/Common/Stateful/Statics.cs b/src/Common/Stateful/Statics.cs index a3fbccc3e..09e38a48a 100644 --- a/src/Common/Stateful/Statics.cs +++ b/src/Common/Stateful/Statics.cs @@ -7,9 +7,11 @@ public static class Statics { public static string AppType = "unknown"; public static string MetricPrefix = "p2g"; - public static string TracingService = "p2g"; + public static string TracingService = "p2g"; + + public static string DefaultConfigDirectory = Environment.GetEnvironmentVariable($"{Constants.EnvironmentVariablePrefix}_CONFIG_DIRECTORY") ?? Environment.CurrentDirectory; - public static string DefaultDataDirectory = Environment.CurrentDirectory; + public static string DefaultDataDirectory = Path.GetFullPath(Path.Join(Environment.CurrentDirectory, "data")); public static string DefaultTempDirectory = Path.Join(Environment.CurrentDirectory, "working"); public static string DefaultOutputDirectory = Path.Join(Environment.CurrentDirectory, "output"); diff --git a/src/ConsoleClient/Program.cs b/src/ConsoleClient/Program.cs index 636cdeebc..2a638b9e2 100644 --- a/src/ConsoleClient/Program.cs +++ b/src/ConsoleClient/Program.cs @@ -37,10 +37,10 @@ static IHostBuilder CreateHostBuilder(string[] args) { configBuilder.Sources.Clear(); - var configPath = Environment.CurrentDirectory; - if (args.Length > 0) configPath = args[0]; + var configDirectory = Statics.DefaultConfigDirectory; + if (args.Length > 0) configDirectory = args[0]; - Statics.ConfigPath = Path.Join(configPath, "configuration.local.json"); + Statics.ConfigPath = Path.Join(configDirectory, "configuration.local.json"); configBuilder .AddJsonFile(Statics.ConfigPath, optional: true, reloadOnChange: true) diff --git a/src/WebUI/Program.cs b/src/WebUI/Program.cs index da2173c5c..6a6c0fce4 100644 --- a/src/WebUI/Program.cs +++ b/src/WebUI/Program.cs @@ -12,7 +12,7 @@ Statics.AppType = Constants.WebUIName; Statics.MetricPrefix = Constants.WebUIName; Statics.TracingService = Constants.WebUIName; -Statics.ConfigPath = Path.Join(Environment.CurrentDirectory, "configuration.local.json"); +Statics.ConfigPath = Path.Join(Statics.DefaultConfigDirectory, "configuration.local.json"); /////////////////////////////////////////////////////////// /// HOST @@ -20,7 +20,7 @@ var builder = WebApplication.CreateBuilder(args); var configProvider = builder.Configuration.AddJsonFile(Statics.ConfigPath, optional: true, reloadOnChange: true) - .AddEnvironmentVariables(prefix: "P2G_") + .AddEnvironmentVariables(prefix: $"{Constants.EnvironmentVariablePrefix}_") .AddCommandLine(args); var config = new AppConfiguration(); diff --git a/vNextReleaseNotes.md b/vNextReleaseNotes.md index 970f4fde8..9cfd1af87 100644 --- a/vNextReleaseNotes.md +++ b/vNextReleaseNotes.md @@ -1,28 +1,24 @@ [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/philosowaffle) Buy Me A Coffee donate button --- -## Fixes +## Features -- [#683] Initial fix for Garmin Upload error. Additionally introduces new settings for configuring Garmin Api. - -> [!CAUTION] -> **Windows App Users** -> When editing settings, you may encounter an issue where your mouse stops working within the P2G app. Keyboard navigation continues to work. If this happens, quit P2G and restart. I will be investigating how to get a proper fix for this on a future release. +- [#698] If using docker, you can now mount the config directory instead of the config file itself. Additionally, the location of the config directory can be overriddien via environment variable: `P2G_CONFIG_DIRECTORY`. ## Docker Tags - Console - `console-stable` - `console-latest` - - `console-v4.3.1` + - `console-v4.4.0` - `console-v4` - Api - `api-stable` - `api-latest` - - `api-v4.3.1` + - `api-v4.4.0` - `api-v4` - WebUI - `webui-stable` - `webui-latest` - - `webui-v4.3.1` + - `webui-v4.4.0` - `webui-v4`