Skip to content

Commit

Permalink
Add Aspire host
Browse files Browse the repository at this point in the history
Add an Aspire app host.
  • Loading branch information
martincostello committed Apr 29, 2024
1 parent 2cb0a6e commit 0e943eb
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ jobs:
~/.cache/ms-playwright
~/Library/Caches/ms-playwright
- name: Install .NET Workloads
shell: pwsh
run: dotnet workload restore

- name: Build, test and publish
shell: pwsh
run: ./build.ps1
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ jobs:

- name: Autobuild
uses: github/codeql-action/autobuild@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3
if: matrix.language != 'csharp'

- name: Build .NET code
if: matrix.language == 'csharp'
run: |
dotnet workload restore
dotnet build --configuration Release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3
Expand Down
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<GlobalPackageReference Include="ReferenceTrimmer" Version="3.3.6" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Aspire.Hosting.AppHost" Version="8.0.0-preview.6.24214.1" />
<PackageVersion Include="Aspire.Hosting.Azure.CosmosDB" Version="8.0.0-preview.6.24214.1" />
<PackageVersion Include="Aspire.Microsoft.Azure.Cosmos" Version="8.0.0-preview.6.24214.1" />
<PackageVersion Include="AspNet.Security.OAuth.Amazon" Version="8.0.0" />
<PackageVersion Include="AspNet.Security.OAuth.Apple" Version="8.0.0" />
<PackageVersion Include="AspNet.Security.OAuth.GitHub" Version="8.0.0" />
Expand Down
7 changes: 7 additions & 0 deletions LondonTravel.Site.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\ossf-scorecard.yml = .github\workflows\ossf-scorecard.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LondonTravel.Site.AppHost", "src\LondonTravel.Site.AppHost\LondonTravel.Site.AppHost.csproj", "{4C191691-65C5-4C8A-85AD-D8C55E6AD6C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -78,6 +80,10 @@ Global
{0106CA34-73B0-4F30-8BDF-AF8D7AB22A4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0106CA34-73B0-4F30-8BDF-AF8D7AB22A4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0106CA34-73B0-4F30-8BDF-AF8D7AB22A4A}.Release|Any CPU.Build.0 = Release|Any CPU
{4C191691-65C5-4C8A-85AD-D8C55E6AD6C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C191691-65C5-4C8A-85AD-D8C55E6AD6C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C191691-65C5-4C8A-85AD-D8C55E6AD6C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C191691-65C5-4C8A-85AD-D8C55E6AD6C4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -89,6 +95,7 @@ Global
{4F53FEF1-66BC-45ED-B563-A619E9A193B7} = {DD7EA67A-4FE1-4D4F-825E-51FF842107AB}
{4AD9EC06-329C-47FB-8549-1A1EDE980130} = {DD7EA67A-4FE1-4D4F-825E-51FF842107AB}
{22736F26-BC95-4792-915C-B6E61FEB523A} = {4F53FEF1-66BC-45ED-B563-A619E9A193B7}
{4C191691-65C5-4C8A-85AD-D8C55E6AD6C4} = {0EED3EF2-37DE-4E6E-B766-3E641D163515}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {612E5D09-113B-4494-BEE6-0376224726FE}
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ To build and test the website run the following commands from your terminal of c
```powershell
git clone https://github.com/martincostello/alexa-london-travel-site.git
cd alexa-london-travel-site
# Restore Aspire workload on first usage (requires elevation on Windows if not installed)
dotnet workload restore
# Build and test the application
./build.ps1
```

Expand Down
14 changes: 14 additions & 0 deletions src/LondonTravel.Site.AppHost/LondonTravel.Site.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsAspireHost>true</IsAspireHost>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
<PackageReference Include="Aspire.Hosting.Azure.CosmosDB" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LondonTravel.Site\LondonTravel.Site.csproj" />
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions src/LondonTravel.Site.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Martin Costello, 2017. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.

var builder = DistributedApplication.CreateBuilder(args);

var cosmos = builder.AddAzureCosmosDB("Cosmos")
.RunAsEmulator();

builder.AddProject<Projects.LondonTravel_Site>("LondonTravelSite")
.WithReference(cosmos);

var app = builder.Build();

app.Run();
17 changes: 17 additions & 0 deletions src/LondonTravel.Site.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"AppHost": {
"commandName": "Project",
"applicationUrl": "https://localhost:15292;http://localhost:15293",
"dotnetRunMessages": true,
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16099",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037"
}
}
}
}
8 changes: 8 additions & 0 deletions src/LondonTravel.Site.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions src/LondonTravel.Site.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Aspire.Hosting.Dcp": "Warning",
"Microsoft.AspNetCore": "Warning"
}
}
}
1 change: 1 addition & 0 deletions src/LondonTravel.Site/LondonTravel.Site.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<ContainerLabel Include="com.docker.extension.publisher-url" Value="$(GITHUB_SERVER_URL)/$(GITHUB_REPOSITORY_OWNER)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aspire.Microsoft.Azure.Cosmos" />
<PackageReference Include="AspNet.Security.OAuth.Amazon" />
<PackageReference Include="AspNet.Security.OAuth.Apple" />
<PackageReference Include="AspNet.Security.OAuth.GitHub" />
Expand Down
2 changes: 2 additions & 0 deletions src/LondonTravel.Site/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@

builder.Services.AddSingleton(TimeProvider.System);
builder.Services.AddSingleton<ITflServiceFactory, TflServiceFactory>();

builder.AddAzureCosmosDBClient("Cosmos");
builder.Services.AddSingleton(DocumentHelpers.CreateClient);
builder.Services.TryAddSingleton<IDocumentService, DocumentService>();
builder.Services.TryAddSingleton<IDocumentCollectionInitializer, DocumentCollectionInitializer>();
Expand Down

0 comments on commit 0e943eb

Please sign in to comment.