/
SonarQube
1FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder 2ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet/tools 3RUN curl -sSL https://deb.nodesource.com/setup_18.x | /bin/bash \ 4&&  apt-get update \ 5&&  apt-get install -y \ 6        openjdk-17-jre-headless \ 7        nodejs \ 8&&  dotnet tool install --global dotnet-sonarscanner 9 10 11WORKDIR /src 12ARG BRANCH_NAME=no_branch_name_specified 13COPY ["Coral.API/Coral.API.csproj",                       "Coral.API/Coral.API.csproj"] 14COPY ["Coral.Application/Coral.Application.csproj",       "Coral.Application/Coral.Application.csproj"] 15COPY ["Coral.Configuration/Coral.Configuration.csproj",   "Coral.Configuration/Coral.Configuration.csproj"] 16COPY ["Coral.Core/Coral - Backup.Entities.csproj",        "Coral.Core/Coral - Backup.Entities.csproj"] 17COPY ["Coral.Core/Coral.Core.csproj",                     "Coral.Core/Coral.Core.csproj"] 18COPY ["Coral.Infrastructure/Coral.Infrastructure.csproj", "Coral.Infrastructure/Coral.Infrastructure.csproj"] 19COPY ["Coral.IdentityServer/Coral.IdentityServer.csproj", "Coral.IdentityServer/Coral.IdentityServer.csproj"] 20COPY ["Coral.sln",                                        "Coral.sln"] 21COPY ["Coral.Lambda/src/Coral.Lambda/Coral.Lambda.csproj", "Coral.Lambda/src/Coral.Lambda/Coral.Lambda.csproj"] 22COPY ["Coral.Lambda/test/Coral.Lambda.Tests/Coral.Lambda.Tests.csproj", "Coral.LambdaC/test/Coral.Lambda.Tests/Coral.Lambda.Tests.csproj"] 23COPY ["Coral.Test/Coral.Test.csproj", "Coral.Test/Coral.Test.csproj"] 24RUN dotnet restore --disable-parallel 25COPY . ./ 26WORKDIR /src/Coral.API 27 28#RUN msbuild "Coral.API.csproj"  29#/p:Configuration=Release 30 31# Sonarqube analysis 32RUN dotnet sonarscanner begin /k:"Coral.API" \ 33/d:sonar.host.url="https://sonarqube.dev.governmentbrands.com/sonarqube" \ 34/d:sonar.login="squ_500145d5074ffd1c2505927d692ed5eb1cc3dbb0" 35RUN dotnet build Coral.API.csproj  36##/p:Configuration=Release 37RUN dotnet sonarscanner end /d:sonar.login="squ_500145d5074ffd1c2505927d692ed5eb1cc3dbb0" 38 39#RUN msbuild "Coral.API.csproj" /p:Configuration=Release 40 41RUN dotnet publish "Coral.API.csproj" -c Release -o /app -p:PublishReadyToRun=true 42FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS runtime 43EXPOSE 5000 44RUN apt-get update && apt-get install -y vim procps 45WORKDIR /app 46COPY --from=builder /app . 47RUN  groupadd --gid 1000 app \ 48  && useradd --uid 1000 --gid app --shell /bin/bash --create-home app 49RUN  chown -R app:app /app 50USER app 51ENTRYPOINT ["./Coral.API", "--urls=http://0.0.0.0:5000"] 52 53 54 55

Docker file with openjdk-17-jre-headless  upgrade and SonarQube Analysis:

1# Sonarqube analysis 2RUN dotnet sonarscanner begin /k:"Coral.API" \ 3/d:sonar.host.url="https://sonarqube.dev.governmentbrands.com/sonarqube" \ 4/d:sonar.login="squ_500145d5074ffd1c2505927d692ed5eb1cc3dbb0" 5RUN dotnet build Coral.API.csproj  6##/p:Configuration=Release 7RUN dotnet sonarscanner end /d:sonar.login="squ_500145d5074ffd1c2505927d692ed5eb1cc3dbb0" 8