Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/core/Synapse.Core/Resources/DockerRuntimeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public DockerRuntimeConfiguration()
/// Gets/sets the configuration of the host to use when running runner containers
/// </summary>
[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();

/// <summary>
/// Gets/sets the path to the directory that contains the secrets to mount in runner containers on a per workflow configuration basis
Expand All @@ -110,4 +110,16 @@ public static Config LoadContainerTemplate()
return YamlSerializer.Default.Deserialize<Config>(yaml)!;
}

/// <summary>
/// Loads the host configuration to use when running runner containers
/// </summary>
/// <returns>The host configuration to use when running runner containers, or <c>null</c> if no host configuration is defined</returns>
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<HostConfig>(yaml);
}

}
4 changes: 4 additions & 0 deletions src/core/Synapse.Core/SynapseDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,10 @@ public static class Docker
/// </summary>
public const string Container = Prefix + "CONTAINER";
/// <summary>
/// Gets the environment variable used to specify the YAML file used to configure the Docker runner host
/// </summary>
public const string Host = Prefix + "HOST";
/// <summary>
/// Gets the environment variable used to configure the network runner containers should be connected to
/// </summary>
public const string Network = Prefix + "NETWORK";
Expand Down
Loading