A base template for .NET 6 WebApi backend Angular 13 SPA frontend.
Here is what I have so far:
- Serilog for logging.
- Dapper for ORM.
- EntityFramework Core as another ORM alternative, so hard to decide (used by OpenIddict too)
- Swashbuckle Swagger and SwaggerUI.
- TODO: cleanup sample db mess and move it into migrations
- TODO: OpenIddict for authentication (IdentityServer seems to have taken a bad turn).
and a Dockerfile for deployment.
There is a sample data load script called sql-dataload.sql
that can populate a sample DB. A few simple scripts for setting up a SQL Server docker container make it fairly straightforward.
- .NET 6.0 Runtime (for the cert stuff, everything else happens in the dev container)
- Docker Desktop
- VSCode w/ Remote - Containers extensions installed
That should be it for the host!
You'll likely have other VSCode extensions for C#, etc...
Initial setup involves sharing and trusting the development TLS cert so that it is trusted on both the host machine (by the browser), and also by the underlying proxy that runs in the docker environment and integrates with the SPA frameworks.
dotnet dev certs is handy for getting all this setup.
- Create the dev certificate. dotnet 6.0 SDK is required on the host machine in order to run the following command:
dotnet dev-certs https -ep ${HOME}/Workspace/certs/dotnetcert.pfx -p { password here }
By including the password both the public and private keys will be embedded in the pfx.
Note: the certificate is exported to ${HOME}/Workspace/certs/
as dotnetcert.pfx
. Subsequent configurations expect this location and naming, and would need to be updated accordingly if changed.
- Trust the certificate on the host machine.
dotnet dev-certs https --trust
The command works it magic installing and trusting the certificate, and many sudo passwords will be entered.
The docker container will mount the host folder ~/Workspcae/certs
, which is then specified in the .devcontainer.json
via the ENV variable for the ASPNET runtime:
"remoteEnv": {
"ASPNETCORE_Kestrel__Certificates__Default__Password": "",
"ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/dotnetcert.pfx"
},
In this way both the containerized ASPNET server and the host browser use the same locally trusted dev certificate (which is bound to the name localhost
).