Skip to content

Commit bc37e0c

Browse files
authored
Filter https service discovery variables. (#8363)
1 parent 60918fb commit bc37e0c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

playground/publishers/Publishers.AppHost/docker-compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ services:
6767
P2: "${PARAM2}"
6868
P3: "${PARAM3}"
6969
services__api__http__0: "http://api:8005"
70-
services__api__https__0: "https://api:8007"
7170
ports:
7271
- "8011:8010"
7372
- "8013:8012"

src/Aspire.Hosting.Docker/DockerComposePublishingContext.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ private async Task ProcessEnvironmentAsync(DistributedApplicationExecutionContex
321321
await c.Callback(context).ConfigureAwait(false);
322322
}
323323

324+
RemoveHttpsServiceDiscoveryVariables(context.EnvironmentVariables);
325+
324326
foreach (var kv in context.EnvironmentVariables)
325327
{
326328
var value = await ProcessValueAsync(kv.Value).ConfigureAwait(false);
@@ -329,6 +331,23 @@ private async Task ProcessEnvironmentAsync(DistributedApplicationExecutionContex
329331
}
330332
}
331333
}
334+
335+
private static void RemoveHttpsServiceDiscoveryVariables(Dictionary<string, object> environmentVariables)
336+
{
337+
// HACK: At the moment Docker Compose doesn't do anything with setting up certificates so
338+
// we need to remove the https service discovery variables.
339+
340+
var keysToRemove = environmentVariables
341+
.Where(kvp => kvp.Value is EndpointReference epRef && epRef.Scheme == "https" && kvp.Key.StartsWith("services__"))
342+
.Select(kvp => kvp.Key)
343+
.ToList();
344+
345+
foreach (var key in keysToRemove)
346+
{
347+
environmentVariables.Remove(key);
348+
}
349+
}
350+
332351
private void ProcessVolumes()
333352
{
334353
if (!resource.TryGetContainerMounts(out var mounts))

0 commit comments

Comments
 (0)