microsoft / microsoft/aspire

Aspire.Host.Docker - resource published as docker-compose service, although PublishAsDockerComposeService not applied.

Open
#12,932 3 comments 0 reactions 0 assignees View on GitHub
area-integrations orleans
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

Having code:
```
var builder = DistributedApplication.CreateBuilder(args);
var kafkaConnectionString = builder.AddConnectionString("kafka");
var compose = builder.AddDockerComposeEnvironment("compose")
var redis = builder.AddRedis("redis", 6379)
var testOrleans= builder.AddOrleans("test-orleans")
.WithClustering(redis)
.WithClusterId("test1")
.WithServiceId("test1");

var silo = builder.AddProject("test")
.WithReference(testOrleans)
.WithReference(redis)
.WithReference(kafkaConnectionString)
.WithReplicas(2)
.WaitFor(redis)
.PublishAsDockerComposeService((conf, service) =>
{
service.Name = "test";
})
```

gives ouput:
```
services:
compose-dashboard:
image: "mcr.microsoft.com/dotnet/nightly/aspire-dashboard:latest"
expose:
- "18888"
- "18889"
networks:
- "aspoire"
restart: "always"
redis:
image: "docker.io/library/redis:8.2"
command:
- "-c"
- "redis-server --requirepass $$REDIS_PASSWORD"
entrypoint:
- "/bin/sh"
environment:
REDIS_PASSWORD: "${REDIS_PASSWORD}"
expose:
- "6379"
networks:
- "aspire"
test:
image: "${TEST_IMAGE}"
...
```

### Expected Behavior

redis should be registered as environment variable, and not as a service, otherwise what is the point of calling PublishAsDockerComposeService.

In case if redis is shipped as standalone service in production environment, it should not be published as service in docker-compose. But should work only on local aspire run/debug. If someone wants to ship redis as part of docker-compose, he should apply PublishAsDockerComposeService method on redis resource.

### .NET Version info

10.0.100

aspire 13.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.