-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ProperDockerfile): 100 points if
dotnet build
or `dotnet publi…
…sh` exists docs(ProperDockerfile): Removed empty list item
- Loading branch information
Vincent Mahnke
committed
Mar 9, 2023
1 parent
eeed8bb
commit c209e83
Showing
7 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...dGenerator.Test/Checks/ProperDockerfile/Result100/DotnetPublishAndSonarscanner.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build | ||
WORKDIR /src | ||
COPY ["CoolService.csproj", "CoolService/"] | ||
RUN dotnet restore "CoolService.csproj" | ||
COPY . . | ||
WORKDIR "CoolService" | ||
RUN dotnet publish "CoolService.csproj" -c Release -o /app/build | ||
|
||
FROM build AS test | ||
WORKDIR "CoolService" | ||
RUN dotnet test "CoolService.csproj" -c Release -o /app/test | ||
|
||
FROM build AS publish | ||
RUN dotnet tool install --global dotnet-sonarscanner | ||
ENV PATH="${PATH}:/root/.dotnet/tools" | ||
RUN dotnet sonarscanner begin /k:"ScorecardGenerator" /d:sonar.host.url="http://sonarqube:9000" /d:sonar.login="admin" /d:sonar.password="admin" | ||
RUN dotnet publish "CoolService.csproj" -c Release -o /app/build | ||
RUN dotnet sonarscanner end /d:sonar.login="admin" /d:sonar.password="admin" | ||
|
||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "CoolService.dll"] |
16 changes: 16 additions & 0 deletions
16
ScorecardGenerator.Test/Checks/ProperDockerfile/Result100/DotnetPublishAndSonarscanner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using ScorecardGenerator.Test.Helper; | ||
using Serilog; | ||
|
||
namespace ScorecardGenerator.Test.Checks.ProperDockerfile.Result100; | ||
|
||
public class DotnetPublishAndSonarscanner : TestWithNeighboringCsprojAndDockerfileFixture | ||
{ | ||
[Test] | ||
public void Returns100Points() | ||
{ | ||
var logger = new LoggerConfiguration().CreateLogger(); | ||
var check = new ScorecardGenerator.Checks.ProperDockerfile.Check(logger); | ||
var deductions = check.SetupLoggerAndRun(AbsolutePathToProjectFile); | ||
deductions.CountAndFinalScore(0, 100); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...dGenerator.Test/Checks/ProperDockerfile/Result100/DotnetPublishAndSonarscanner.csproj.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>disable</Nullable> | ||
<PreserveCompilationContext>true</PreserveCompilationContext> | ||
<RuntimeIdentifier>win10-x64</RuntimeIdentifier> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Content Include="wwwroot\css\site.css" /> | ||
<Content Include="wwwroot\css\site.less" /> | ||
<Content Include="wwwroot\css\site.min.css" /> | ||
<Content Include="wwwroot\favicon.ico" /> | ||
<Content Include="wwwroot\icon.jpg" /> | ||
<Content Include="wwwroot\icon.png" /> | ||
<Content Include="wwwroot\js\signout-redirect.js" /> | ||
<Content Include="wwwroot\lib\bootstrap\css\bootstrap.css" /> | ||
<Content Include="wwwroot\lib\bootstrap\css\bootstrap.css.map" /> | ||
<Content Include="wwwroot\lib\bootstrap\css\bootstrap.min.css" /> | ||
<Content Include="wwwroot\lib\bootstrap\fonts\glyphicons-halflings-regular.eot" /> | ||
<Content Include="wwwroot\lib\bootstrap\fonts\glyphicons-halflings-regular.svg" /> | ||
<Content Include="wwwroot\lib\bootstrap\fonts\glyphicons-halflings-regular.ttf" /> | ||
<Content Include="wwwroot\lib\bootstrap\fonts\glyphicons-halflings-regular.woff" /> | ||
<Content Include="wwwroot\lib\bootstrap\fonts\glyphicons-halflings-regular.woff2" /> | ||
<Content Include="wwwroot\lib\bootstrap\js\bootstrap.js" /> | ||
<Content Include="wwwroot\lib\bootstrap\js\bootstrap.min.js" /> | ||
<Content Include="wwwroot\lib\jquery\jquery.js" /> | ||
<Content Include="wwwroot\lib\jquery\jquery.min.js" /> | ||
<Content Include="wwwroot\lib\jquery\jquery.min.map" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="IdentityServer4" Version="1.1.0" /> | ||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.0"> | ||
<HintPath>..\..\..\..\..\..\thangchung.HARVEYNASH\.nuget\packages\identityserver4\1.1.0\lib\net452\IdentityServer4.dll</HintPath> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0"> | ||
<HintPath>..\..\..\..\..\..\thangchung.HARVEYNASH\.nuget\packages\identityserver4\1.1.0\lib\net452\IdentityServer4.dll</HintPath> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="1.1.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="1.1.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters