Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/Aspire.Cli/Templating/DotNetTemplateFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ private IEnumerable<ITemplate> GetTemplatesCore(bool showAllTemplates)
TemplatingStrings.AspirePyStarter_Description,
projectName => $"./{projectName}",
_ => { },
ApplySingleFileTemplate
(template, parseResult, ct) => ApplySingleFileTemplate(template, parseResult, PromptForExtraAspirePythonStarterOptionsAsync, ct)
);

yield return new CallbackTemplate(
"aspire-apphost-singlefile",
TemplatingStrings.AspireAppHostSingleFile_Description,
projectName => $"./{projectName}",
_ => { },
ApplySingleFileTemplate
ApplySingleFileTemplateWithNoExtraArgsAsync
);
}

Expand Down Expand Up @@ -146,6 +146,15 @@ private async Task<string[]> PromptForExtraAspireStarterOptionsAsync(ParseResult
return extraArgs.ToArray();
}

private async Task<string[]> PromptForExtraAspirePythonStarterOptionsAsync(ParseResult result, CancellationToken cancellationToken)
{
var extraArgs = new List<string>();

await PromptForRedisCacheOptionAsync(result, extraArgs, cancellationToken);

return extraArgs.ToArray();
}

private async Task<string[]> PromptForExtraAspireXUnitOptionsAsync(ParseResult result, CancellationToken cancellationToken)
{
var extraArgs = new List<string>();
Expand Down Expand Up @@ -253,7 +262,16 @@ private async Task<TemplateResult> ApplyTemplateWithNoExtraArgsAsync(CallbackTem
return await ApplyTemplateAsync(template, parseResult, (_, _) => Task.FromResult(Array.Empty<string>()), cancellationToken);
}

private async Task<TemplateResult> ApplySingleFileTemplate(CallbackTemplate template, ParseResult parseResult, CancellationToken cancellationToken)
private Task<TemplateResult> ApplySingleFileTemplateWithNoExtraArgsAsync(CallbackTemplate template, ParseResult parseResult, CancellationToken cancellationToken)
{
return ApplySingleFileTemplate(
template,
parseResult,
(_, _) => Task.FromResult(Array.Empty<string>()),
cancellationToken);
}

private async Task<TemplateResult> ApplySingleFileTemplate(CallbackTemplate template, ParseResult parseResult, Func<ParseResult, CancellationToken, Task<string[]>> extraArgsCallback, CancellationToken cancellationToken)
{
if (parseResult.CommandResult.Command is InitCommand)
{
Expand All @@ -262,7 +280,7 @@ private async Task<TemplateResult> ApplySingleFileTemplate(CallbackTemplate temp
executionContext.WorkingDirectory.Name,
executionContext.WorkingDirectory.FullName,
parseResult,
(_, _) => Task.FromResult(Array.Empty<string>()),
extraArgsCallback,
cancellationToken
);
}
Expand All @@ -271,7 +289,7 @@ private async Task<TemplateResult> ApplySingleFileTemplate(CallbackTemplate temp
return await ApplyTemplateAsync(
template,
parseResult,
(_, _) => Task.FromResult(Array.Empty<string>()),
extraArgsCallback,
cancellationToken
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"NoHttps": {
"longName": "no-https",
"shortName": ""
},
"UseRedisCache": {
"longName": "use-redis-cache",
"shortName": ""
}
},
"usageExamples": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
{
"id": "vs"
}
],
"symbolInfo": [
{
"id": "UseRedisCache",
"isVisible": true,
"persistenceScope": "templateGroup"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"author": "Microsoft",
"name": "Aspire Python Starter App",
"description": "A project template for creating an Aspire app with a Python backend API service and a JavaScript frontend using Vite and React.",
"symbols/UseRedisCache/displayName": "_Use Redis for caching (requires a supported container runtime)",
"symbols/UseRedisCache/description": "Configures whether to setup the application to use Redis for caching. Requires a supported container runtime to run locally, see https://aka.ms/dotnet/aspire/containers for more details.",
"symbols/appHostHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json of the AppHost project.",
"symbols/appHostOtlpHttpPort/description": "Port number to use for the OTLP HTTP endpoint in launchSettings.json of the AppHost project.",
"symbols/appHostResourceHttpPort/description": "Port number to use for the resource service HTTP endpoint in launchSettings.json of the AppHost project.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
}
],
"symbols": {
"UseRedisCache": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"displayName": "_Use Redis for caching (requires a supported container runtime)",
"description": "Configures whether to setup the application to use Redis for caching. Requires a supported container runtime to run locally, see https://aka.ms/dotnet/aspire/containers for more details."
},
"appHostHttpPort": {
"type": "parameter",
"datatype": "integer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ WORKDIR /app

# Install dependencies first for better layer caching
# Uses BuildKit cache mounts to speed up repeated builds
RUN --mount=type=cache,target=/root/.cache/uv --mount=type=bind,source=./api_service/uv.lock,target=uv.lock --mount=type=bind,source=./api_service/pyproject.toml,target=pyproject.toml \
RUN --mount=type=cache,target=/root/.cache/uv --mount=type=bind,source=./app/uv.lock,target=uv.lock --mount=type=bind,source=./app/pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-dev

# Copy the rest of the application source and install the project
COPY ./api_service /app
COPY ./app /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev

Expand Down
Loading