diff --git a/src/core/Synapse.Core/Resources/DockerRuntimeConfiguration.cs b/src/core/Synapse.Core/Resources/DockerRuntimeConfiguration.cs index 2cea7f60..8abc63b4 100644 --- a/src/core/Synapse.Core/Resources/DockerRuntimeConfiguration.cs +++ b/src/core/Synapse.Core/Resources/DockerRuntimeConfiguration.cs @@ -84,7 +84,7 @@ public DockerRuntimeConfiguration() /// Gets/sets the configuration of the host to use when running runner containers /// [DataMember(Order = 5, Name = "hostConfig"), JsonPropertyOrder(5), JsonPropertyName("hostConfig"), YamlMember(Order = 5, Alias = "hostConfig")] - public virtual HostConfig? HostConfig { get; set; } + public virtual HostConfig? HostConfig { get; set; } = LoadHostConfig(); /// /// Gets/sets the path to the directory that contains the secrets to mount in runner containers on a per workflow configuration basis @@ -110,4 +110,16 @@ public static Config LoadContainerTemplate() return YamlSerializer.Default.Deserialize(yaml)!; } + /// + /// Loads the host configuration to use when running runner containers + /// + /// The host configuration to use when running runner containers, or null if no host configuration is defined + public static HostConfig? LoadHostConfig() + { + var hostConfigFilePath = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Host); + if (string.IsNullOrWhiteSpace(hostConfigFilePath) || !File.Exists(hostConfigFilePath)) return null; + var yaml = File.ReadAllText(hostConfigFilePath); + return YamlSerializer.Default.Deserialize(yaml); + } + } diff --git a/src/core/Synapse.Core/SynapseDefaults.cs b/src/core/Synapse.Core/SynapseDefaults.cs index 54e4571c..2525dc38 100644 --- a/src/core/Synapse.Core/SynapseDefaults.cs +++ b/src/core/Synapse.Core/SynapseDefaults.cs @@ -730,6 +730,10 @@ public static class Docker /// public const string Container = Prefix + "CONTAINER"; /// + /// Gets the environment variable used to specify the YAML file used to configure the Docker runner host + /// + public const string Host = Prefix + "HOST"; + /// /// Gets the environment variable used to configure the network runner containers should be connected to /// public const string Network = Prefix + "NETWORK";