@@ -30,7 +30,7 @@ internal sealed class DockerComposePublishingContext(
30
30
CancellationToken cancellationToken = default )
31
31
{
32
32
public readonly IResourceContainerImageBuilder ImageBuilder = imageBuilder ;
33
-
33
+ public readonly DockerComposePublisherOptions PublisherOptions = publisherOptions ;
34
34
public readonly PortAllocator PortAllocator = new ( ) ;
35
35
private readonly Dictionary < string , ( string Description , string ? DefaultValue ) > _env = [ ] ;
36
36
private readonly Dictionary < IResource , ComposeServiceContext > _composeServices = [ ] ;
@@ -48,7 +48,7 @@ internal async Task WriteModelAsync(DistributedApplicationModel model)
48
48
logger . StartGeneratingDockerCompose ( ) ;
49
49
50
50
ArgumentNullException . ThrowIfNull ( model ) ;
51
- ArgumentNullException . ThrowIfNull ( publisherOptions . OutputPath ) ;
51
+ ArgumentNullException . ThrowIfNull ( PublisherOptions . OutputPath ) ;
52
52
53
53
if ( model . Resources . Count == 0 )
54
54
{
@@ -58,7 +58,7 @@ internal async Task WriteModelAsync(DistributedApplicationModel model)
58
58
59
59
await WriteDockerComposeOutputAsync ( model ) . ConfigureAwait ( false ) ;
60
60
61
- logger . FinishGeneratingDockerCompose ( publisherOptions . OutputPath ) ;
61
+ logger . FinishGeneratingDockerCompose ( PublisherOptions . OutputPath ) ;
62
62
}
63
63
64
64
public void AddEnv ( string name , string description , string ? defaultValue = null )
@@ -70,7 +70,7 @@ private async Task WriteDockerComposeOutputAsync(DistributedApplicationModel mod
70
70
{
71
71
var defaultNetwork = new Network
72
72
{
73
- Name = publisherOptions . ExistingNetworkName ?? "aspire" ,
73
+ Name = PublisherOptions . ExistingNetworkName ?? "aspire" ,
74
74
Driver = "bridge" ,
75
75
} ;
76
76
@@ -105,8 +105,8 @@ private async Task WriteDockerComposeOutputAsync(DistributedApplicationModel mod
105
105
}
106
106
107
107
var composeOutput = composeFile . ToYaml ( ) ;
108
- var outputFile = Path . Combine ( publisherOptions . OutputPath ! , "docker-compose.yaml" ) ;
109
- Directory . CreateDirectory ( publisherOptions . OutputPath ! ) ;
108
+ var outputFile = Path . Combine ( PublisherOptions . OutputPath ! , "docker-compose.yaml" ) ;
109
+ Directory . CreateDirectory ( PublisherOptions . OutputPath ! ) ;
110
110
await File . WriteAllTextAsync ( outputFile , composeOutput , cancellationToken ) . ConfigureAwait ( false ) ;
111
111
112
112
if ( _env . Count == 0 )
@@ -117,7 +117,7 @@ private async Task WriteDockerComposeOutputAsync(DistributedApplicationModel mod
117
117
118
118
// Write a .env file with the environment variable names
119
119
// that are used in the compose file
120
- var envFile = Path . Combine ( publisherOptions . OutputPath ! , ".env" ) ;
120
+ var envFile = Path . Combine ( PublisherOptions . OutputPath ! , ".env" ) ;
121
121
using var envWriter = new StreamWriter ( envFile ) ;
122
122
123
123
foreach ( var entry in _env )
@@ -200,7 +200,10 @@ private record struct EndpointMapping(string Scheme, string Host, int InternalPo
200
200
201
201
public async Task < Service > BuildComposeServiceAsync ( CancellationToken cancellationToken )
202
202
{
203
- await composePublishingContext . ImageBuilder . BuildImageAsync ( resource , cancellationToken ) . ConfigureAwait ( false ) ;
203
+ if ( composePublishingContext . PublisherOptions . BuildImages )
204
+ {
205
+ await composePublishingContext . ImageBuilder . BuildImageAsync ( resource , cancellationToken ) . ConfigureAwait ( false ) ;
206
+ }
204
207
205
208
if ( ! TryGetContainerImageName ( resource , out var containerImageName ) )
206
209
{
0 commit comments