Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkerkhove authored Jul 14, 2023
2 parents ed6f037 + 89c5fcd commit d61a158
Show file tree
Hide file tree
Showing 27 changed files with 164 additions and 53 deletions.
2 changes: 2 additions & 0 deletions build/azure-devops/agents-ci-discovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ stages:
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Resource Discovery'
testRunTitle: 'resource-discovery-linux'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
Expand Down Expand Up @@ -164,6 +165,7 @@ stages:
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Resource Discovery'
testRunTitle: 'resource-discovery-windows'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
Expand Down
2 changes: 2 additions & 0 deletions build/azure-devops/agents-ci-scraper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ stages:
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Scraper'
testRunTitle: 'scraper-linux'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
Expand Down Expand Up @@ -250,6 +251,7 @@ stages:
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Scraper'
testRunTitle: 'scraper-windows'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ stages:
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Resource Discovery'
testRunTitle: 'resource-discovery-linux'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
Expand Down Expand Up @@ -189,6 +190,7 @@ stages:
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Resource Discovery'
testRunTitle: 'resource-discovery-windows'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
Expand Down
18 changes: 10 additions & 8 deletions build/azure-devops/agents-scraper-release-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ stages:
- template: templates/docker/show-running-containers.yml
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Scraper'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
agentName: 'Scraper'
testRunTitle: 'scraper-linux'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.Scraper.Name)'
Expand Down Expand Up @@ -261,11 +262,12 @@ stages:
networkName: '$(Container.Network.Name)'
os: '$(OS.Name)'
- template: templates/docker/show-running-containers.yml
#- template: templates/tests/run-integration-tests.yml
# parameters:
# agentName: 'Scraper'
# dotnetVersion: '$(DotNet.Sdk.Version)'
# buildConfiguration: '$(DotNet.Configuration)'
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Scraper'
testRunTitle: 'scraper-windows'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.Scraper.Name)'
Expand Down
3 changes: 3 additions & 0 deletions build/azure-devops/templates/tests/run-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
parameters:
- name: agentName
type: string
- name: testRunTitle
type: string
- name: dotnetVersion
type: string
- name: buildConfiguration
Expand Down Expand Up @@ -30,4 +32,5 @@ steps:
projects: 'src/Promitor.Tests.Integration/Promitor.Tests.Integration.csproj'
feedsToUse: 'config'
nugetConfigPath: 'src/NuGet.config'
testRunTitle: ${{ parameters.testRunTitle }}
arguments: '--configuration ${{ parameters.buildConfiguration }} --filter "Agent=${{ parameters.agentName}}"'
2 changes: 1 addition & 1 deletion build/azure-devops/variables/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
variables:
DotNet.Sdk.Version: '7.0.304'
DotNet.Sdk.Version: '7.0.305'
DotNet.Configuration: 'release'
6 changes: 4 additions & 2 deletions changelog/content/experimental/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ version:

#### Scraper

None.
- {{% tag changed %}} Switch to Mariner distroless base images
- {{% tag security %}} Patch for [CVE-2023-29331](https://github.com/advisories/GHSA-555c-2p6r-68mm) (High)

#### Resource Discovery

None.
- {{% tag changed %}} Switch to Mariner distroless base images
- {{% tag security %}} Patch for [CVE-2023-29331](https://github.com/advisories/GHSA-555c-2p6r-68mm) (High)
6 changes: 3 additions & 3 deletions src/Promitor.Agents.Core/Promitor.Agents.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<RuntimeFrameworkVersion>7.0.7</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion>7.0.8</RuntimeFrameworkVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand All @@ -21,10 +21,10 @@
<PackageReference Include="CronScheduler.AspNetCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.8" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
<PackageReference Include="Prometheus.Client" Version="5.2.0" />
<PackageReference Include="Prometheus.Client.AspNetCore" Version="4.8.0" />
<PackageReference Include="Prometheus.Client.AspNetCore" Version="5.0.0" />
<PackageReference Include="Prometheus.Client.HttpRequestDurations" Version="3.6.0" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
Expand Down
56 changes: 52 additions & 4 deletions src/Promitor.Agents.ResourceDiscovery/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0.304-alpine3.17 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.305-cbl-mariner2.0 AS build
WORKDIR /src
ARG VERSION="UNSET-VERSION"
COPY Promitor.Agents.ResourceDiscovery/* Promitor.Agents.ResourceDiscovery/
Expand All @@ -13,13 +13,61 @@ COPY Promitor.Integrations.LogAnalytics/* Promitor.Integrations.LogAnalytics/
COPY Promitor.Integrations.Sinks.Prometheus/* Promitor.Integrations.Sinks.Prometheus/
RUN dotnet publish Promitor.Agents.ResourceDiscovery/Promitor.Agents.ResourceDiscovery.csproj --configuration release --output /app /p:Version=$VERSION

FROM mcr.microsoft.com/dotnet/aspnet:7.0.7-alpine3.17 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.8-cbl-mariner2.0-distroless AS runtime-base

FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS installer

RUN tdnf install -y fdupes \
&& tdnf clean all

COPY --from=runtime-base / /staging1
COPY --from=runtime-base / /staging2

# See https://docs.microsoft.com/en-us/dotnet/core/runtime-config/globalization
RUN tdnf install -y --releasever=2.0 --installroot /staging2 icu \
&& tdnf clean all --releasever=2.0 --installroot /staging2

# Prepare the staging2 directory to be copied to the final stage by removing unnecessary files
# that will only cause extra image bloat.
RUN \
# Remove duplicates from staging2 that exist in staging1
fdupes /staging1 /staging2 -rdpN \
\
# Delete duplicate symlinks
# Function to find and format symlinks w/o including root dir (format: /path/to/symlink /path/to/target)
&& getsymlinks() { find $1 -type l -printf '%p %l\n' | sed -n "s/^\\$1\\(.*\\)/\\1/p"; } \
# Combine set of symlinks between staging1 and staging2
&& (getsymlinks "/staging1"; getsymlinks "/staging2") \
# Sort them
| sort \
# Find the duplicates
| uniq -d \
# Extract just the path to the symlink
| cut -d' ' -f1 \
# Prepend the staging2 directory to the paths
| sed -e 's/^/\/staging2/' \
# Delete the files
| xargs rm \
\
# General cleanup
&& rm -rf /staging2/etc/tdnf \
&& rm -rf /staging2/run/* \
&& rm -rf /staging2/var/cache/tdnf \
&& rm -rf /staging2/var/lib/rpm \
&& rm -rf /staging2/usr/share/doc \
&& rm -rf /staging2/usr/share/man \
&& find /staging2/var/log -type f -size +0 -delete \
\
# Delete empty directories
&& find /staging2 -type d -empty -delete

FROM runtime-base AS runtime
COPY --from=installer /staging2/ /

WORKDIR /app
ENV PROMITOR_CONFIG_FOLDER="/config/"
COPY --from=build /app .

# See https://docs.microsoft.com/en-us/dotnet/core/runtime-config/globalization
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

ENTRYPOINT ["dotnet", "Promitor.Agents.ResourceDiscovery.dll"]
4 changes: 2 additions & 2 deletions src/Promitor.Agents.ResourceDiscovery/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0.304 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.305 AS build
WORKDIR /src
ARG VERSION="UNSET-VERSION"
COPY Promitor.Agents.ResourceDiscovery/* Promitor.Agents.ResourceDiscovery/
Expand All @@ -13,7 +13,7 @@ COPY Promitor.Integrations.LogAnalytics/* Promitor.Integrations.LogAnalytics/
COPY Promitor.Integrations.Sinks.Prometheus/* Promitor.Integrations.Sinks.Prometheus/
RUN dotnet publish Promitor.Agents.ResourceDiscovery/Promitor.Agents.ResourceDiscovery.csproj --configuration release --output /app /p:Version=%VERSION%

FROM mcr.microsoft.com/dotnet/aspnet:7.0.7 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.8 AS runtime
WORKDIR /app
ENV PROMITOR_CONFIG_FOLDER="c:/config/"
COPY --from=build /app .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<RuntimeFrameworkVersion>7.0.7</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion>7.0.8</RuntimeFrameworkVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>Docs\Open-Api.xml</DocumentationFile>
<UserSecretsId>159d036b-3697-40d4-bdc4-7d9736521375</UserSecretsId>
Expand Down Expand Up @@ -42,6 +42,7 @@

<!-- Explicitly pin dependencies on container project to mitigate security vulnerabilities -->
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="7.0.3" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="7.0.1" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>
Expand Down
56 changes: 52 additions & 4 deletions src/Promitor.Agents.Scraper/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0.304-alpine3.17 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.305-cbl-mariner2.0 AS build
WORKDIR /src
ARG VERSION="UNSET-VERSION"
COPY Promitor.Core/* Promitor.Core/
Expand All @@ -17,12 +17,60 @@ COPY Promitor.Integrations.Sinks.Statsd/* Promitor.Integrations.Sinks.Statsd/
COPY Promitor.Agents.Scraper/* Promitor.Agents.Scraper/
RUN dotnet publish Promitor.Agents.Scraper/Promitor.Agents.Scraper.csproj --configuration release --output app /p:Version=$VERSION

FROM mcr.microsoft.com/dotnet/aspnet:7.0.7-alpine3.17 as runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.8-cbl-mariner2.0-distroless AS runtime-base

FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS installer

RUN tdnf install -y fdupes \
&& tdnf clean all

COPY --from=runtime-base / /staging1
COPY --from=runtime-base / /staging2

# See https://docs.microsoft.com/en-us/dotnet/core/runtime-config/globalization
RUN tdnf install -y --releasever=2.0 --installroot /staging2 icu \
&& tdnf clean all --releasever=2.0 --installroot /staging2

# Prepare the staging2 directory to be copied to the final stage by removing unnecessary files
# that will only cause extra image bloat.
RUN \
# Remove duplicates from staging2 that exist in staging1
fdupes /staging1 /staging2 -rdpN \
\
# Delete duplicate symlinks
# Function to find and format symlinks w/o including root dir (format: /path/to/symlink /path/to/target)
&& getsymlinks() { find $1 -type l -printf '%p %l\n' | sed -n "s/^\\$1\\(.*\\)/\\1/p"; } \
# Combine set of symlinks between staging1 and staging2
&& (getsymlinks "/staging1"; getsymlinks "/staging2") \
# Sort them
| sort \
# Find the duplicates
| uniq -d \
# Extract just the path to the symlink
| cut -d' ' -f1 \
# Prepend the staging2 directory to the paths
| sed -e 's/^/\/staging2/' \
# Delete the files
| xargs rm \
\
# General cleanup
&& rm -rf /staging2/etc/tdnf \
&& rm -rf /staging2/run/* \
&& rm -rf /staging2/var/cache/tdnf \
&& rm -rf /staging2/var/lib/rpm \
&& rm -rf /staging2/usr/share/doc \
&& rm -rf /staging2/usr/share/man \
&& find /staging2/var/log -type f -size +0 -delete \
\
# Delete empty directories
&& find /staging2 -type d -empty -delete

FROM runtime-base AS runtime
COPY --from=installer /staging2/ /

WORKDIR /app
ENV PROMITOR_CONFIG_FOLDER="/config/"

# See https://docs.microsoft.com/en-us/dotnet/core/runtime-config/globalization
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

COPY --from=build /src/app .
Expand Down
4 changes: 2 additions & 2 deletions src/Promitor.Agents.Scraper/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0.304 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.305 AS build
WORKDIR /src
ARG VERSION="UNSET-VERSION"
COPY Promitor.Core/* Promitor.Core/
Expand All @@ -17,7 +17,7 @@ COPY Promitor.Integrations.Sinks.Statsd/* Promitor.Integrations.Sinks.Statsd/
COPY Promitor.Agents.Scraper/* Promitor.Agents.Scraper/
RUN dotnet publish Promitor.Agents.Scraper/Promitor.Agents.Scraper.csproj --configuration release --output app /p:Version=%VERSION%

FROM mcr.microsoft.com/dotnet/aspnet:7.0.7 as runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.8 as runtime
WORKDIR /app
ENV PROMITOR_CONFIG_FOLDER="c:/config/"

Expand Down
7 changes: 4 additions & 3 deletions src/Promitor.Agents.Scraper/Promitor.Agents.Scraper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<RuntimeFrameworkVersion>7.0.7</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion>7.0.8</RuntimeFrameworkVersion>
<!--<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>-->
</PropertyGroup>

Expand Down Expand Up @@ -37,13 +37,14 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="CronExpressionDescriptor" Version="2.19.0" />
<PackageReference Include="CronExpressionDescriptor" Version="2.20.0" />
<PackageReference Include="Microsoft.Azure.Kusto.Language" Version="11.3.2" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="YamlDotNet" Version="13.1.0" />
<PackageReference Include="YamlDotNet" Version="13.1.1" />

<!-- Explicitly pin dependencies on container project to mitigate security vulnerabilities -->
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="7.0.3" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="7.0.1" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Promitor.Core.Contracts/Promitor.Core.Contracts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<RuntimeFrameworkVersion>7.0.7</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion>7.0.8</RuntimeFrameworkVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
4 changes: 2 additions & 2 deletions src/Promitor.Core.Scraping/Promitor.Core.Scraping.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<RuntimeFrameworkVersion>7.0.7</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion>7.0.8</RuntimeFrameworkVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>

Expand All @@ -21,7 +21,7 @@
<PackageReference Include="Guard.Net" Version="3.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.38.1" />
<PackageReference Include="YamlDotNet" Version="13.1.0" />
<PackageReference Include="YamlDotNet" Version="13.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Promitor.Core/Promitor.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<RuntimeFrameworkVersion>7.0.7</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion>7.0.8</RuntimeFrameworkVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand All @@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.Azure.Management.Monitor.Fluent" Version="1.38.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="YamlDotNet" Version="13.1.0" />
<PackageReference Include="YamlDotNet" Version="13.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit d61a158

Please sign in to comment.