Skip to content

Commit b8602fd

Browse files
authored
feat: replace docker compose with dotnet aspire (#223)
1 parent ea5c957 commit b8602fd

File tree

21 files changed

+86
-100
lines changed

21 files changed

+86
-100
lines changed

Chapter-1-initial-architecture/README.adoc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,13 @@ to download it from the official Microsoft website.
197197

198198
=== Run locally
199199

200-
The Fitnet application requires Docker to run properly.
200+
The Fitnet application uses .NET Aspire for local development.
201201

202-
There are only 3 steps you need to start the application:
202+
To run the application locally, follow these steps:
203203

204-
1. Make sure that you are in `/Src` directory.
205-
2. Run `docker-compose build` to build the image of the application.
206-
3. Run `docker-compose up` to start the application. In the meantime it will also start Postgres inside container.
207-
208-
The application runs on port `:8080`. Please navigate to http://localhost:8080 in your browser or http://localhost:8080/swagger/index.html to explore the API.
209-
210-
That's it! You should now be able to run the application using either one of the above. :thumbsup:
204+
1. **Ensure Docker is running** on your machine.
205+
2. **Navigate to the solution root directory** in your terminal.
206+
3. **Run the AppHost project using the following command:**
211207

212208
=== How to run Integration Tests?
213209
To run the integration tests for the project located in the `Fitnet.IntegrationTests` project, you can use either the command:

Chapter-1-initial-architecture/Src/Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0"/>
3+
4+
<PropertyGroup>
5+
<OutputType>Exe</OutputType>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsAspireHost>true</IsAspireHost>
9+
<UserSecretsId>b4ef32d8-9e82-4dd1-b9a7-bc43e2c564e9</UserSecretsId>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0"/>
14+
<PackageReference Include="Aspire.Hosting.PostgreSQL" Version="9.0.0"/>
15+
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\Fitnet\Fitnet.csproj"/>
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Projects;
2+
3+
var builder = DistributedApplication.CreateBuilder(args);
4+
var postgres = builder.AddPostgres("postgres")
5+
.WithImage("postgres", "15.15")
6+
.WithPgAdmin();
7+
8+
var fitnetDatabase = postgres.AddDatabase("fitnetsdb", "fitnet");
9+
builder.AddProject<Fitnet>("fitnet")
10+
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
11+
.WithReference(fitnetDatabase, "Passes")
12+
.WithReference(fitnetDatabase, "Contracts")
13+
.WithReference(fitnetDatabase, "Reports")
14+
.WithReference(fitnetDatabase, "Offers")
15+
.WaitFor(postgres);
16+
17+
await builder.Build().RunAsync();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"https": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "https://localhost:17105;http://localhost:15107",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_ENVIRONMENT": "Development",
12+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21129",
13+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22189"
14+
}
15+
}
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning",
6+
"Aspire.Hosting.Dcp": "Warning"
7+
}
8+
}
9+
}

Chapter-1-initial-architecture/Src/Fitnet.ArchitectureTests/Fitnet.ArchitectureTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2323
<PrivateAssets>all</PrivateAssets>
2424
</PackageReference>
25-
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.14.0.120626" />
25+
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
2626
</ItemGroup>
2727

2828
<ItemGroup>

Chapter-1-initial-architecture/Src/Fitnet.IntegrationTests/Fitnet.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3030
<PrivateAssets>all</PrivateAssets>
3131
</PackageReference>
32-
<PackageReference Update="SonarAnalyzer.CSharp" Version="9.32.0.97167" />
32+
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
3333
</ItemGroup>
3434

3535
<ItemGroup>

Chapter-1-initial-architecture/Src/Fitnet.UnitTests/Fitnet.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2424
<PrivateAssets>all</PrivateAssets>
2525
</PackageReference>
26-
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.14.0.120626" />
26+
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
2727
</ItemGroup>
2828

2929
<ItemGroup>
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Solution>
2-
<Project Path="Fitnet.ArchitectureTests\Fitnet.ArchitectureTests.csproj" Type="Classic C#" />
3-
<Project Path="Fitnet.IntegrationTests\Fitnet.IntegrationTests.csproj" Type="Classic C#" />
4-
<Project Path="Fitnet.UnitTests\Fitnet.UnitTests.csproj" Type="Classic C#" />
5-
<Project Path="Fitnet\Fitnet.csproj" Type="Classic C#" />
2+
<Project Path="Fitnet.AppHost/Fitnet.AppHost.csproj" />
3+
<Project Path="Fitnet.ArchitectureTests\Fitnet.ArchitectureTests.csproj" Type="C#" />
4+
<Project Path="Fitnet.IntegrationTests\Fitnet.IntegrationTests.csproj" Type="C#" />
5+
<Project Path="Fitnet.UnitTests\Fitnet.UnitTests.csproj" Type="C#" />
6+
<Project Path="Fitnet\Fitnet.csproj" Type="C#" />
67
</Solution>

0 commit comments

Comments
 (0)