diff --git a/README.md b/README.md index 5160c5c1..524e0bf8 100644 --- a/README.md +++ b/README.md @@ -23,20 +23,21 @@ The documentation sources are located in the `docs` directory. See the [docs rea ## Development -This section describes how to set up the development environment. First, you need to install the following tools: +This section describes how to set up the development environment. First, you need to install the following tools installed on your machine: +- Docker - .NET 10.0 SDK -- node.js v24.x and npm -- your favourite IDE +- Node.js v24.x and npm +- [JetBrains Rider](https://www.jetbrains.com/rider/) (free for non-commercial use) or [Visual Studio](https://visualstudio.microsoft.com/vs/) To run the application from source, follow these steps: -1. Open the `src/Turnierplan.slnx` solution and navigate to the docker compose file located under `Solution Items`. Run the `turnierplan.database` docker compose service. This will start up the PostgreSQL database for local development. -2. Navigate to the `Turnierplan.App` project and run the `Turnierplan.App` launch configuration. This will start the backend using port `45000`. -3. Open a terminal and navigate to the `src/Turnierplan.App/Client` directory. Run `npm install` to install the node dependencies. Next, you can start the client application by typing `npm run start`. -4. Access the client application using [http://localhost:45001](http://localhost:45001) and log in using default credentials. The user name is `admin` and the password is `P@ssw0rd`. +1. Open the `src/Turnierplan.slnx` solution. +2. Run the `Turnierplan.AppHost` project. This will start the Aspire AppHost which will do the following steps: + - Download the postgres container imgage and run a local database + - Install npm dependencies and run the client app + - Run the backend `Turnierplan.App` +3. The Aspire dashboard will open up from which you can navigate to the client application ([http://localhost:45001](http://localhost:45001)). +4. Now you can log in using default credentials: The user name is `admin` and the password is `P@ssw0rd`. When running locally, the API documentation can be viewed by opening [http://localhost:45000/scalar](http://localhost:45000/scalar). - -> [!NOTE] -> The solution must be built first before the client application can be started. This is because the client application startup depends on OpenAPI files generated during the solution build. diff --git a/src/Turnierplan.AppHost/AppHost.cs b/src/Turnierplan.AppHost/AppHost.cs new file mode 100644 index 00000000..4a5d23ad --- /dev/null +++ b/src/Turnierplan.AppHost/AppHost.cs @@ -0,0 +1,23 @@ +using Projects; + +var builder = DistributedApplication.CreateBuilder(args); + +var database = builder.AddPostgres("Turnierplan-Postgres") + .WithDataVolume() + .WithLifetime(ContainerLifetime.Persistent) + .AddDatabase("Turnierplan-Database"); + +builder.AddProject("Turnierplan-Backend") + .WaitFor(database) + .WithHttpHealthCheck("/health") + .WithEnvironment("Database__ConnectionString", database.Resource.ConnectionStringExpression); + +builder.AddJavaScriptApp("Turnierplan-Client", "../Turnierplan.App/Client") + .WithRunScript("start") + .WithHttpEndpoint(45001, isProxied: false) + .WithHttpHealthCheck("/index.html") + .WithNpm(installCommand: "ci"); + +builder.Build().Run(); + +// TODO: Add OpenTelemetry collection diff --git a/src/Turnierplan.AppHost/Properties/launchSettings.json b/src/Turnierplan.AppHost/Properties/launchSettings.json new file mode 100644 index 00000000..387a5a24 --- /dev/null +++ b/src/Turnierplan.AppHost/Properties/launchSettings.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "Turnierplan.AppHost": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15285", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19065", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18247", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20277" + } + } + } +} diff --git a/src/Turnierplan.AppHost/Turnierplan.AppHost.csproj b/src/Turnierplan.AppHost/Turnierplan.AppHost.csproj new file mode 100644 index 00000000..98d509bd --- /dev/null +++ b/src/Turnierplan.AppHost/Turnierplan.AppHost.csproj @@ -0,0 +1,20 @@ + + + + + net10.0 + enable + enable + Exe + 523f324d-1695-4d45-a000-a79765a1468a + + + + + + + + + + + diff --git a/src/Turnierplan.AppHost/appsettings.Development.json b/src/Turnierplan.AppHost/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/src/Turnierplan.AppHost/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/Turnierplan.AppHost/appsettings.json b/src/Turnierplan.AppHost/appsettings.json new file mode 100644 index 00000000..31c092aa --- /dev/null +++ b/src/Turnierplan.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/src/docker-compose.yml b/src/docker-compose.yml deleted file mode 100644 index 31727155..00000000 --- a/src/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - turnierplan.database: - image: postgres:17.0 - environment: - - POSTGRES_PASSWORD=P@ssw0rd - - POSTGRES_DB=turnierplan - volumes: - - turnierplan-data:/var/lib/postgresql/data - ports: - - "5432:5432" - restart: unless-stopped - -volumes: - turnierplan-data: - diff --git a/src/turnierplan.NET.slnx b/src/turnierplan.NET.slnx index ba0e0a96..03a88477 100644 --- a/src/turnierplan.NET.slnx +++ b/src/turnierplan.NET.slnx @@ -1,6 +1,5 @@ - @@ -15,6 +14,7 @@ +