/// <summary>
 /// Initializes a new instance of the <see cref="DockerContainerManager"/> class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="dockerConfiguration"></param>
 public DockerContainerManager(ContainerResourceSettings settings,
                               DockerConfiguration dockerConfiguration)
 {
     _settings            = settings;
     _dockerConfiguration = dockerConfiguration;
     _client = new DockerClientConfiguration(
         LocalDockerUri(),
         null,
         TimeSpan.FromMinutes(5)
         )
               .CreateClient(Version.Parse("1.25"));
     _authConfig = GetAuthConfig();
 }
Esempio n. 2
0
        public static DockerConfiguration DefaultDockerConfigResolver()
        {
            IConfigurationRoot configuration = new ConfigurationBuilder()
                                               .AddJsonFile("appsettings.json", true)
                                               .AddJsonFile("appsettings.user.json", true)
                                               .AddEnvironmentVariables()
                                               .Build();

            IConfigurationSection section = configuration.GetSection("Squadron:Docker");

            DockerConfiguration containerConfig = section.Get <DockerConfiguration>();

            return(containerConfig ?? new DockerConfiguration());
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the resources
        /// </summary>
        public async virtual Task InitializeAsync()
        {
            ResourceOptions = new TOptions();
            var builder = ContainerResourceBuilder.New();

            ResourceOptions.Configure(builder);
            Settings = builder.Build();

            SetComposeVariables();
            OnSettingsBuilded(Settings);
            ValidateSettings(Settings);

            DockerConfiguration dockerConfig = Settings.DockerConfigResolver();

            Manager     = new DockerContainerManager(Settings, dockerConfig);
            Initializer = new ContainerInitializer(Manager, Settings);
            await Manager.CreateAndStartContainerAsync();
        }