Skip to content

Commit 3721f4e

Browse files
Added sample files
1 parent 8eef658 commit 3721f4e

38 files changed

+4139
-0
lines changed

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
bin
2+
obj
3+
packages
4+
5+
src/**/*.js
6+
src/**/*.js.map
7+
src/**/*.css
8+
src/**/css/**/*.css
9+
src/mvc-sample-app/tslint-report/
10+
11+
.vs/
12+
site
13+
publish
14+
*.pubxml
15+
*.user
16+
*.bat
17+
!src/mvc-sample-app/watch.bat
18+
*.txt
19+
!StagingServer.pubxml
20+
!LocalMachine.pubxml
21+
node_modules
22+
!DeleteNodePackages.bat
23+
!InstallNpmModules.bat
24+
tools
25+
!tools/packages.config
26+
TestResult.xml
27+
cireports
28+
lib
29+
dist
30+
StyleCop.Cache
31+
*StyleCopAnalysis.xml
32+
*JSLintAnalysis.html
33+
*TSLintAnalysis.xml
34+
system.cachebuster.json
35+
*SASSLintAnalysis.html
36+
temporaryfiles
37+
.vscode

Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM mcr.microsoft.com/dotnet/core/aspnet:5.0-alpine AS base
2+
3+
WORKDIR /app
4+
EXPOSE 80
5+
EXPOSE 443
6+
7+
FROM mcr.microsoft.com/dotnet/core/sdk:5.0-buster AS build
8+
9+
#Installing nodejs
10+
11+
RUN apt-get update -yq \
12+
&& apt-get install curl gnupg -yq \
13+
&& curl -sL https://deb.nodesource.com/setup_10.x | bash \
14+
&& apt-get install nodejs -yq
15+
16+
#Installing gulp
17+
18+
RUN npm install -g gulp
19+
20+
WORKDIR /src
21+
22+
COPY ["src/sample-library-proj/sample-library-proj.csproj.csproj", "src/sample-library-proj/"]
23+
COPY ["src/mvc-sample-app/mvc-sample-app.csproj", "src/mvc-sample-app/"]
24+
COPY ["src/mvc-sample-app/package.json", "src/mvc-sample-app/"]
25+
COPY *.config .
26+
27+
WORKDIR "/src/src/mvc-sample-app"
28+
29+
#Installing npm packages
30+
RUN npm install
31+
32+
WORKDIR /src
33+
34+
RUN dotnet restore "src/mvc-sample-app/mvc-sample-app.csproj" --disable-parallel --configfile ./nuget.config
35+
COPY . .
36+
WORKDIR "/src/src/mvc-sample-app"
37+
38+
#setting release mode for node packages and webpacking
39+
ENV NODE_ENV="Release"
40+
RUN npm install -g webpack
41+
RUN npm install -g webpack-cli
42+
RUN gulp build
43+
RUN dotnet build "mvc-sample-app.csproj" -c Release -o /app/build
44+
45+
FROM build AS publish
46+
RUN dotnet publish "mvc-sample-app.csproj" -c Release -o /app/publish
47+
48+
FROM base AS final
49+
WORKDIR /app
50+
51+
52+
ENV ApplicationDetails__SecretKey=SecretKeyPassedThroughEnvironmentVariable
53+
ENV AppSettings__EnableHTTPS="false"
54+
55+
56+
COPY --from=publish /app/publish .
57+
ENTRYPOINT ["dotnet", "mvc-sample-app.dll"]

mvc-sample-app.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30717.126
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mvc-sample-app", "src\mvc-sample-app\mvc-sample-app.csproj", "{319D6F84-4670-4E85-B22C-5EF0A8F5733F}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sample-library-proj", "src\sample-library-proj\sample-library-proj.csproj", "{06B7CE72-A773-4F48-AA38-2B80FBEBB985}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{319D6F84-4670-4E85-B22C-5EF0A8F5733F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{319D6F84-4670-4E85-B22C-5EF0A8F5733F}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{319D6F84-4670-4E85-B22C-5EF0A8F5733F}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{319D6F84-4670-4E85-B22C-5EF0A8F5733F}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{06B7CE72-A773-4F48-AA38-2B80FBEBB985}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{06B7CE72-A773-4F48-AA38-2B80FBEBB985}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{06B7CE72-A773-4F48-AA38-2B80FBEBB985}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{06B7CE72-A773-4F48-AA38-2B80FBEBB985}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {B179FE79-A531-494C-BCD4-591680CF2AA8}
30+
EndGlobalSection
31+
EndGlobal

nuget.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
5+
</packageSources>
6+
</configuration>

src/mvc-sample-app/.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

src/mvc-sample-app/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2+
3+
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
4+
WORKDIR /app
5+
EXPOSE 80
6+
EXPOSE 443
7+
8+
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
9+
WORKDIR /src
10+
COPY ["mvc-sample-app.csproj", ""]
11+
RUN dotnet restore "./mvc-sample-app.csproj"
12+
COPY . .
13+
WORKDIR "/src/."
14+
RUN dotnet build "mvc-sample-app.csproj" -c Release -o /app/build
15+
16+
FROM build AS publish
17+
RUN dotnet publish "mvc-sample-app.csproj" -c Release -o /app/publish
18+
19+
FROM base AS final
20+
WORKDIR /app
21+
COPY --from=publish /app/publish .
22+
ENTRYPOINT ["dotnet", "mvc-sample-app.dll"]

src/mvc-sample-app/Pages/Error.cshtml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using Microsoft.Extensions.Logging;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Diagnostics;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
10+
namespace mvc_sample_app.Pages
11+
{
12+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13+
[IgnoreAntiforgeryToken]
14+
public class ErrorModel : PageModel
15+
{
16+
public string RequestId { get; set; }
17+
18+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
19+
20+
private readonly ILogger<ErrorModel> _logger;
21+
22+
public ErrorModel(ILogger<ErrorModel> logger)
23+
{
24+
_logger = logger;
25+
}
26+
27+
public void OnGet()
28+
{
29+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
30+
}
31+
}
32+
}

src/mvc-sample-app/Pages/Index.cshtml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
}
6+
7+
<div class="text-center">
8+
<h1 class="display-4">Welcome</h1>
9+
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
10+
<button id="button">Click Here</button>
11+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using Microsoft.Extensions.Logging;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
9+
namespace mvc_sample_app.Pages
10+
{
11+
public class IndexModel : PageModel
12+
{
13+
private readonly ILogger<IndexModel> _logger;
14+
15+
public IndexModel(ILogger<IndexModel> logger)
16+
{
17+
_logger = logger;
18+
}
19+
20+
public void OnGet()
21+
{
22+
23+
}
24+
}
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model PrivacyModel
3+
@{
4+
ViewData["Title"] = "Privacy Policy";
5+
}
6+
<h1>@ViewData["Title"]</h1>
7+
8+
<p>Use this page to detail your site's privacy policy.</p>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using Microsoft.Extensions.Logging;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
9+
namespace mvc_sample_app.Pages
10+
{
11+
public class PrivacyModel : PageModel
12+
{
13+
private readonly ILogger<PrivacyModel> _logger;
14+
15+
public PrivacyModel(ILogger<PrivacyModel> logger)
16+
{
17+
_logger = logger;
18+
}
19+
20+
public void OnGet()
21+
{
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)