Sample ASP.NET Core Web App for Razor reference application, powered by Codebelt, based on the standard project generated by Microsoft.
There are two ways to use this reference application:
You can clone this project: git clone https://github.com/codebeltnet/webapp-razor-refapp.git
-or-
Open Powershell and run the following command to install the solution template:
dotnet new --install Codebelt.Template.WebApp.RazorThis installs the ASP.NET Core Web App by Codebelt template globally on your machine and can then be used from either Visual Studio UI or .NET CLI. If the latter is chosen, navigate to a new directory where you want to place the solution, and copy the path of the opened directory (eg. %USERPROFILE%\source\repos\MyRazorApp).
Run the following command:
dotnet new cb-webapp -o C:\Users\gimlichael\source\repos\MyRazorAppIn this example I am naming my new solution MyRazorApp and my %USERPROFILE% points to C:\Users\gimlichael. The rest should be pretty self explanatory.
Note:
- Environment is set to
LocalDevelopment - The
approotandcdnrootfolder should only be used locally, eg.LocalDevelopmentenvironment
The solution file, docker-compose and preview nuget sources is placed in the root of the repo.
The project itself, Codebelt.Template.WebApp.Razor, is placed in src.
Example of structure:
/Codebelt.Template.WebApp.Razor.sln
/docker-compose.yml
/NuGet.config
/src/Codebelt.Template.WebApp.Razor/approot/<static files tailored to the app>
/src/Codebelt.Template.WebApp.Razor/cdnroot/<static files shared by many>
/src/Codebelt.Template.WebApp.Razor/Pages/<default razor pages by Microsoft>
/src/Codebelt.Template.WebApp.Razor/appsettings.Development.json
/src/Codebelt.Template.WebApp.Razor/appsettings.json
/src/Codebelt.Template.WebApp.Razor/appsettings.LocalDevelopment.json
/src/Codebelt.Template.WebApp.Razor/appsettings.Production.json
/src/Codebelt.Template.WebApp.Razor/appsettings.Staging.json
/src/Codebelt.Template.WebApp.Razor/Codebelt.Template.WebApp.Razor.csproj
/src/Codebelt.Template.WebApp.Razor/Dockerfile
/src/Codebelt.Template.WebApp.Razor/Dockerfile.app-static
/src/Codebelt.Template.WebApp.Razor/Dockerfile.cdn-static
/src/Codebelt.Template.WebApp.Razor/Program.cs
/src/Codebelt.Template.WebApp.Razor/Startup.cs
All Codebelt projects work with 4 different types of environments, where only one deviates from industry standards; LocalDevelopment.
However, more often than not, we need to have an environment that was thought out to be an isolated environment for developer machines, eg. allow more relaxed rules in terms of user secrets, local dependencies and so forth.
Development, in particular, should be used for centralized developer testing before pushing changes to Staging.
LocalDevelopment(typically where the app is being forged)Development(centralized developer testing of the app)Staging(dress rehearsal of the app)Production(done-done - we are live)
Development, Staging and Production should be environments outside the developers machine, as these (depending on your setup) are part of the CI/CD flow and used for their respective scopes.
The 3 Docker files each has there own role:
Dockerfile(the app itself)Dockerfile.app-static(the static files tied to the app)Dockerfile.cdn-static(the static files suited to be shared between your apps on a CDN)
As a quick example I have spun up 3 environments matching what is defined in appsettings.Development.json, appsettings.Staging.json and appsettings.Production.json.
CDN is setup on Azure using a source origins poiting to dev-cdn.codebelt.net, stg-cdn.codebelt.net and cdn.codebelt.net.
This is just to provide seed of inspiration.
You can test the 3 environments yourself (nothing fancy; just the sample code provided by Microsoft adjusted to "static content separation"):
- Development - https://dev-webapp-razor.codebelt.net/
- Staging - https://stg-webapp-razor.codebelt.net/
- Production - https://webapp-razor.codebelt.net/
Code with passion; love your code; deliver with confidence 👨💻️🔥❤️🚀