Skip to content

Commit 704c8fd

Browse files
committed
feat: Add option for private registries
1 parent be04aca commit 704c8fd

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

DockerDiscordBot/Services/DockerService.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public sealed class DockerService : IDockerService
1111
{
1212
private readonly DockerClient _client;
1313
private readonly ILogger<DockerService> _logger;
14+
private readonly ApplicationSettings _options;
1415

1516
public DockerService(
1617
IOptions<ApplicationSettings> options,
@@ -20,6 +21,7 @@ public DockerService(
2021
_client = new DockerClientConfiguration(
2122
new Uri(options.Value.DockerHost))
2223
.CreateClient();
24+
_options = options.Value;
2325
}
2426

2527
public async Task<IList<ContainerListResponse>?> GetAllContainersAsync(CancellationToken cancellationToken)
@@ -190,7 +192,12 @@ await _client.Images.CreateImageAsync(
190192
FromImage = image,
191193
Tag = tag
192194
},
193-
new AuthConfig(),
195+
new AuthConfig
196+
{
197+
ServerAddress = _options.DockerRegistryUrl,
198+
Username = _options.DockerRegistryUsername,
199+
Password = _options.DockerRegistryPassword
200+
},
194201
new Progress<JSONMessage>(),
195202
cancellationToken);
196203
return true;

DockerDiscordBot/Settings/ApplicationSettings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ public sealed class ApplicationSettings
66
public required string DockerHost { get; init; }
77
public string AdminUser { get; init; } = string.Empty;
88
public required string CommandPrefix { get; init; }
9+
public string DockerRegistryUrl { get; init; } = string.Empty;
10+
public string DockerRegistryUsername { get; init; } = string.Empty;
11+
public string DockerRegistryPassword { get; init; } = string.Empty;
912
}

DockerDiscordBot/appsettings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"DiscordToken": "",
1818
"DockerHost": "unix:///var/run/docker.sock",
1919
"AdminUser": "",
20-
"CommandPrefix": "!"
20+
"CommandPrefix": "!",
21+
"DockerRegistryUrl": "",
22+
"DockerRegistryUsername": "",
23+
"DockerRegistryPassword": ""
2124
}
2225
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ The bot can be configured using environment variables:
8080
| `ApplicationSettings__DiscordToken` | Discord bot token | `null` | ✅ |
8181
| `ApplicationSettings__AdminUser` | Discord admin username | `null` | ❌ |
8282
| `ApplicationSettings__CommandPrefix` | Command prefix | `!` | ❌ |
83+
| `ApplicationSettings__DockerRegistryUrl` | Private registry url | `null` | ❌ |
84+
| `ApplicationSettings__DockerRegistryUsername` | Private registry username | `null` | ❌ |
85+
| `ApplicationSettings__DockerRegistryPassword` | Private registry password | `null` | ❌ |
8386

8487
## License
8588

Todo.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)