Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Commit d51dc54

Browse files
committed
Added Dockerfile, update project to .NET Core 6
1 parent 22d4ab0 commit d51dc54

File tree

82 files changed

+52366
-18274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+52366
-18274
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
**/bin
15+
**/charts
16+
**/docker-compose*
17+
**/compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
README.md
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal AS base
2+
WORKDIR /app
3+
EXPOSE 5289
4+
5+
ENV ASPNETCORE_URLS=http://+:5289
6+
7+
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
8+
# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers
9+
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
10+
USER appuser
11+
12+
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
13+
WORKDIR /src
14+
COPY ["Code.csproj", "./"]
15+
RUN dotnet restore "Code.csproj"
16+
COPY . .
17+
WORKDIR "/src/."
18+
RUN dotnet build "Code.csproj" -c Release -o /app/build
19+
20+
FROM build AS publish
21+
RUN dotnet publish "Code.csproj" -c Release -o /app/publish /p:UseAppHost=false
22+
23+
FROM base AS final
24+
WORKDIR /app
25+
COPY --from=publish /app/publish .
26+
ENTRYPOINT ["dotnet", "Code.dll"]

L07-02 Multi Stage Build/L07_02_Multi_Stage_Build.csproj

Lines changed: 0 additions & 8 deletions
This file was deleted.

L07-02 Multi Stage Build/Pages/Error.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@page
1+
@page
22
@model ErrorModel
33
@{
44
ViewData["Title"] = "Error";
Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.Diagnostics;
4-
using System.Linq;
5-
using System.Threading.Tasks;
62
using Microsoft.AspNetCore.Mvc;
73
using Microsoft.AspNetCore.Mvc.RazorPages;
8-
using Microsoft.Extensions.Logging;
94

10-
namespace L07_02_Multi_Stage_Build.Pages
5+
namespace Code.Pages;
6+
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
1110
{
12-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13-
[IgnoreAntiforgeryToken]
14-
public class ErrorModel : PageModel
15-
{
16-
public string RequestId { get; set; }
11+
public string? RequestId { get; set; }
1712

18-
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1914

20-
private readonly ILogger<ErrorModel> _logger;
15+
private readonly ILogger<ErrorModel> _logger;
2116

22-
public ErrorModel(ILogger<ErrorModel> logger)
23-
{
24-
_logger = logger;
25-
}
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
2621

27-
public void OnGet()
28-
{
29-
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
30-
}
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
3125
}
3226
}
27+
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Mvc;
1+
using Microsoft.AspNetCore.Mvc;
62
using Microsoft.AspNetCore.Mvc.RazorPages;
7-
using Microsoft.Extensions.Logging;
83

9-
namespace L07_02_Multi_Stage_Build.Pages
4+
namespace Code.Pages;
5+
6+
public class IndexModel : PageModel
107
{
11-
public class IndexModel : PageModel
12-
{
13-
private readonly ILogger<IndexModel> _logger;
8+
private readonly ILogger<IndexModel> _logger;
149

15-
public IndexModel(ILogger<IndexModel> logger)
16-
{
17-
_logger = logger;
18-
}
10+
public IndexModel(ILogger<IndexModel> logger)
11+
{
12+
_logger = logger;
13+
}
1914

20-
public void OnGet()
21-
{
15+
public void OnGet()
16+
{
2217

23-
}
2418
}
2519
}

L07-02 Multi Stage Build/Pages/Privacy.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@page
1+
@page
22
@model PrivacyModel
33
@{
44
ViewData["Title"] = "Privacy Policy";
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Mvc;
1+
using Microsoft.AspNetCore.Mvc;
62
using Microsoft.AspNetCore.Mvc.RazorPages;
7-
using Microsoft.Extensions.Logging;
83

9-
namespace L07_02_Multi_Stage_Build.Pages
4+
namespace Code.Pages;
5+
6+
public class PrivacyModel : PageModel
107
{
11-
public class PrivacyModel : PageModel
12-
{
13-
private readonly ILogger<PrivacyModel> _logger;
8+
private readonly ILogger<PrivacyModel> _logger;
149

15-
public PrivacyModel(ILogger<PrivacyModel> logger)
16-
{
17-
_logger = logger;
18-
}
10+
public PrivacyModel(ILogger<PrivacyModel> logger)
11+
{
12+
_logger = logger;
13+
}
1914

20-
public void OnGet()
21-
{
22-
}
15+
public void OnGet()
16+
{
2317
}
2418
}
19+

L07-02 Multi Stage Build/Pages/Shared/_Layout.cshtml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>@ViewData["Title"] - L07_02_Multi_Stage_Build</title>
6+
<title>@ViewData["Title"] - Code</title>
77
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
8-
<link rel="stylesheet" href="~/css/site.css" />
8+
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
9+
<link rel="stylesheet" href="~/Code.styles.css" asp-append-version="true" />
910
</head>
1011
<body>
1112
<header>
1213
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
1314
<div class="container">
14-
<a class="navbar-brand" asp-area="" asp-page="/Index">L07_02_Multi_Stage_Build</a>
15-
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
15+
<a class="navbar-brand" asp-area="" asp-page="/Index">Code</a>
16+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
1617
aria-expanded="false" aria-label="Toggle navigation">
1718
<span class="navbar-toggler-icon"></span>
1819
</button>
@@ -37,7 +38,7 @@
3738

3839
<footer class="border-top footer text-muted">
3940
<div class="container">
40-
&copy; 2021 - L07_02_Multi_Stage_Build - <a asp-area="" asp-page="/Privacy">Privacy</a>
41+
&copy; 2022 - Code - <a asp-area="" asp-page="/Privacy">Privacy</a>
4142
</div>
4243
</footer>
4344

@@ -47,4 +48,4 @@
4748

4849
@await RenderSectionAsync("Scripts", required: false)
4950
</body>
50-
</html>
51+
</html>

0 commit comments

Comments
 (0)