Skip to content

Commit

Permalink
#2219 Upgrade Docker, CircleCI and update to net8.0, net9.0 targe…
Browse files Browse the repository at this point in the history
…t frameworks (#2230)

* Update Docker

* Upgrade all packages and Microsoft artifacts:
1. to the most recent versions available
2. ideally to version 9.0.*

* Fix compilation errors

* Fix warnings except NU1902:

CS0618: 'DiscoveryApplicationBuilderExtensions.UseDiscoveryClient(IApplicationBuilder)' is obsolete: 'This method call is no longer needed, you should remove it.'

MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Users\rmaks\.nuget\packages\microsoft.servicefabric.data\7.1.2493\lib\netstandard2.0\Microsoft.ServiceFabric.Data.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

SYSLIB0057: 'X509Certificate2.X509Certificate2(string, string?, X509KeyStorageFlags)' is obsolete: 'Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.'

Ignore NU1902: Package 'IdentityServer4' 4.1.2 has a known moderate severity vulnerability

* Fix IDE messages

* Fix integration tests:
The 'Should_be_able_to_use_token_from_ocelot_a_on_ocelot_b' test related to IdentityServer4 requires migration to .NET 9 or removing

* Build using the Docker image version 9.24.0 (Linux OS, double SDKs)

* Add `BddfyConfig` class to override the default BDDfy report behavior in `Steps`

* Disable BatchProcessors

* IDE0130: Namespace "Ocelot.AcceptanceTests" does not match folder structure, expected "Ocelot.AcceptanceTests.Properties"
Where -> \test\Ocelot.AcceptanceTests\Properties\BddfyConfig.cs L4

* Raynald is refactoring super star!
Warning: Unexpected character sequence in array element value.
Where: samples\Administration\Issue645.postman_collection.json L135+145

* CA1816: A method that is an implementation of Dispose does not call GC.SuppressFinalize; or a method that is not an implementation of Dispose calls GC.SuppressFinalize; or a method calls GC.SuppressFinalize and passes something other than this (Me in Visual Basic).
Where: test\Ocelot.AcceptanceTests\HeaderTests.cs L460

* CA1859: Using concrete types avoids virtual or interface call overhead and enables inlining.
Change type of variable 'client' from 'Ocelot.WebSockets.IClientWebSocket' to 'Ocelot.WebSockets.ClientWebSocketProxy' for improved performance
Where: test\Ocelot.AcceptanceTests\WebSocketTests.cs L128+180

* CA2211: Static fields that are neither constants nor read-only are not thread-safe. Access to such a field must be carefully controlled and requires advanced programming techniques to synchronize access to the class object.
Where: src\Ocelot.Administration\IdentityServerMiddlewareConfigurationProvider.cs L10

* IDE0044: Make field readonly
Where: test\Ocelot.AcceptanceTests\Properties\BddfyConfig.cs L21

* IDE0039 Use local function

* IDE0059 Avoid unnecessary value assignments in your code, as these likely indicate redundant value computations. If the value computation is not redundant and you intend to retain the assignment, then change the assignment target to a local variable whose name starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.

* IDE1006 Naming rule violation: These words must begin with upper case characters

* IDE0079 Remove unnecessary suppression

* IDE0330 Use 'System.Threading.Lock'

* IDE1006 Naming rule violation: These words must begin with upper case characters:
Fix compilation error

* Ignore xUnit1004: Test methods should not be skipped
  • Loading branch information
raman-m authored Dec 6, 2024
1 parent 2e352bc commit a80fe9d
Show file tree
Hide file tree
Showing 60 changed files with 479 additions and 390 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ orbs:
jobs:
build:
docker:
- image: ocelot2/circleci-build:latest
- image: ocelot2/circleci-build:9.24.0
resource_class: medium+
steps:
- checkout
- run: dotnet dev-certs https && dotnet tool restore && dotnet cake
release:
docker:
- image: ocelot2/circleci-build:latest
- image: ocelot2/circleci-build:9.24.0
resource_class: medium+
steps:
- checkout
Expand Down
119 changes: 117 additions & 2 deletions Ocelot.Release.sln

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ using System.Linq;
using System.Text.RegularExpressions;

const string Release = "Release"; // task name, target, and Release config name
const string AllFrameworks = "net6.0;net7.0;net8.0";
const string LatestFramework = "net8.0";
const string AllFrameworks = "net8.0;net9.0";
const string LatestFramework = "net9.0";

var compileConfig = Argument("configuration", Release); // compile

Expand Down Expand Up @@ -96,7 +96,7 @@ Task("Compile")
};
if (target != Release)
{
settings.Framework = LatestFramework; // build using .NET 8 SDK only
settings.Framework = LatestFramework; // build using .NET 9 SDK only
}
string frameworkInfo = string.IsNullOrEmpty(settings.Framework) ? AllFrameworks : settings.Framework;
Information($"Settings {nameof(DotNetBuildSettings.Framework)}: {frameworkInfo}");
Expand Down Expand Up @@ -467,7 +467,7 @@ Task("RunUnitTests")
};
if (target != Release)
{
settings.Framework = LatestFramework; // .NET 8 SDK only
settings.Framework = LatestFramework; // .NET 9 SDK only
}
string frameworkInfo = string.IsNullOrEmpty(settings.Framework) ? AllFrameworks : settings.Framework;
Information($"Settings {nameof(DotNetTestSettings.Framework)}: {frameworkInfo}");
Expand Down Expand Up @@ -520,14 +520,13 @@ Task("RunAcceptanceTests")
var settings = new DotNetTestSettings
{
Configuration = compileConfig,
// Framework = LatestFramework, // .NET 8 SDK only
ArgumentCustomization = args => args
.Append("--no-restore")
.Append("--no-build")
};
if (target != Release)
{
settings.Framework = LatestFramework; // .NET 8 SDK only
settings.Framework = LatestFramework; // .NET 9 SDK only
}
string frameworkInfo = string.IsNullOrEmpty(settings.Framework) ? AllFrameworks : settings.Framework;
Information($"Settings {nameof(DotNetTestSettings.Framework)}: {frameworkInfo}");
Expand All @@ -542,14 +541,13 @@ Task("RunIntegrationTests")
var settings = new DotNetTestSettings
{
Configuration = compileConfig,
// Framework = LatestFramework, // .NET 8 SDK only
ArgumentCustomization = args => args
.Append("--no-restore")
.Append("--no-build")
};
if (target != Release)
{
settings.Framework = LatestFramework; // .NET 8 SDK only
settings.Framework = LatestFramework; // .NET 9 SDK only
}
string frameworkInfo = string.IsNullOrEmpty(settings.Framework) ? AllFrameworks : settings.Framework;
Information($"Settings {nameof(DotNetTestSettings.Framework)}: {frameworkInfo}");
Expand Down
17 changes: 0 additions & 17 deletions docker/8.21.0/Dockerfile.build

This file was deleted.

21 changes: 0 additions & 21 deletions docker/8.21.0/Dockerfile.release

This file was deleted.

11 changes: 0 additions & 11 deletions docker/8.21.0/build.sh

This file was deleted.

19 changes: 6 additions & 13 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine

RUN apk add bash icu-libs krb5-libs libgcc libintl libssl3 libstdc++ zlib git openssh-client

# Install .NET 8 SDK
RUN curl -L --output ./dotnet-install.sh https://dot.net/v1/dotnet-install.sh

RUN chmod u+x ./dotnet-install.sh

# Install .NET 8 SDK (already included in the base image, but listed for consistency)
RUN ./dotnet-install.sh -c 8.0 -i /usr/share/dotnet

# Install .NET 7 SDK
RUN ./dotnet-install.sh -c 7.0 -i /usr/share/dotnet

# Install .NET 6 SDK
RUN ./dotnet-install.sh -c 6.0 -i /usr/share/dotnet

# Generate and export the development certificate
RUN dotnet dev-certs https -ep /certs/cert.pem -p '' && \
chmod 644 /certs/cert.pem
# Generate and export the development SSL certificate
RUN mkdir -p /certs
RUN dotnet dev-certs https -ep /certs/cert.pem -p ''
RUN chmod 644 /certs/cert.pem

ENV ASPNETCORE_URLS="https://+;http://+"
ENV ASPNETCORE_HTTPS_PORT=443
Expand Down
24 changes: 24 additions & 0 deletions docker/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM mcr.microsoft.com/dotnet/sdk:9.0-nanoserver-ltsc2022

# Install PowerShell globally AND RUN powershell -Command "gci"
#RUN dotnet tool install -g powershell && pwsh -Command "gci"
RUN pwsh -Command "gci"

# # Install .NET 8 SDK
USER ContainerAdministrator
RUN pwsh -Command "Invoke-WebRequest -OutFile dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1; gci"
ENV DOTNET_GENERATE_ASPNET_CERTIFICATE=true
RUN pwsh -Command "./dotnet-install.ps1 -Channel 8.0 -InstallDir 'C:\Program Files\dotnet\'; gci -Path C:\\ -Recurse -Include *8.0* -Directory"

#RUN git status
RUN dotnet --info

# Generate and export the development SSL certificate
#RUN mkdir -p certs
#RUN dotnet dev-certs https -ep certs/cert.pem -p ''
#RUN pwsh -Command "dotnet dev-certs https --clean; dotnet dev-certs https; exit 0;"
#RUN pwsh -Command "dotnet dev-certs https --trust; exit 0;"
RUN pwsh -Command "dotnet dev-certs https --check --trust; exit 0;"

#ENV ASPNETCORE_URLS="https://+;http://+" ASPNETCORE_HTTPS_PORT=443
#ENV ASPNETCORE_Kestrel__Certificates__Default__Password="" ASPNETCORE_Kestrel__Certificates__Default__Path=certs/cert.pem
27 changes: 22 additions & 5 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
# docker build

This folder contains the `Dockerfile.*` and `build.sh` script to create the Ocelot build image & container.
This folder contains the `Dockerfile.*` and `build-*.sh` scripts to create the Ocelot build image & container.

## Account
- [Ocelot Gateway Profile | Docker Hub](https://hub.docker.com/u/ocelot2)
- Docker Hub | [Ocelot Gateway](https://hub.docker.com/u/ocelot2)

## Repositories
- [circleci-build](https://hub.docker.com/r/ocelot2/circleci-build)

## ocelot2/circleci-build Tags
- [latest](https://hub.docker.com/layers/ocelot2/circleci-build/latest/images/sha256-981d6f9e6e5ba54f6e044bca6fcf8b5197a8f3e6ce2b3cdfa9e6704ecd2ca969?context=explore) is version 8.23.2, uploaded on Apr 3, 2024.
- [8.23.2](https://hub.docker.com/layers/ocelot2/circleci-build/8.23.2/images/sha256-981d6f9e6e5ba54f6e044bca6fcf8b5197a8f3e6ce2b3cdfa9e6704ecd2ca969?context=explore), uploaded on Apr 3, 2024. It supports development SSL certificates by the command `dotnet dev-certs https`.
## Outdated Tags
- [8.21.0](https://hub.docker.com/layers/ocelot2/circleci-build/8.21.0/images/sha256-edb46d37ab52d39a5b27dc63895e5944d4d491d1788744ed144ecb4303b94532?context=explore), uploaded on Nov 20, 2023. It contains .NET 8, 7 and 6 SDKs. It supports builds for `net6.0`, `net7.0` and `net8.0` frameworks.
- [8.23.2](https://hub.docker.com/layers/ocelot2/circleci-build/8.23.2/images/sha256-981d6f9e6e5ba54f6e044bca6fcf8b5197a8f3e6ce2b3cdfa9e6704ecd2ca969?context=explore), uploaded on Apr 3, 2024. It supports development SSL certificates by the command `dotnet dev-certs https`.
- [latest](https://hub.docker.com/layers/ocelot2/circleci-build/latest/images/sha256-981d6f9e6e5ba54f6e044bca6fcf8b5197a8f3e6ce2b3cdfa9e6704ecd2ca969?context=explore) is version 8.23.2, uploaded on Apr 3, 2024.

## .NET 8-9 Tags

### Single SDK Tags
- [sdk-8-alpine-lin.net8](https://hub.docker.com/layers/ocelot2/circleci-build/sdk-8-alpine-lin.net8/images/sha256-17c21438771641ba2a3320a6c13fe756a851d707a925188d9616485bfc757b22?context=explore), uploaded on Dec 3, 2024. This Linux OS image contains .NET 8 SDK only. It supports builds for `net8.0` framework.
- [sdk-9-alpine-lin.net9](https://hub.docker.com/layers/ocelot2/circleci-build/sdk-9-alpine-lin.net9/images/sha256-c20d82a52c1a7eebf86bcd32751960ae189e6c50575959ee0499b1d88541c9ea?context=explore), uploaded on Dec 3, 2024. This Linux OS image contains .NET 9 SDK only. It supports builds for `net9.0` framework.
- [sdk8-nanoserver2022-win.net8](https://hub.docker.com/layers/ocelot2/circleci-build/sdk8-nanoserver2022-win.net8/images/sha256-20f21f4361d18301bc885e1f01ebefcd6b024802130db1296173cdfaac5d75e6?context=explore), uploaded on Dec 3, 2024. This Windows OS image contains .NET 8 SDK only. It supports builds for `net8.0` framework.
- [sdk9-nano2022-win.net9](https://hub.docker.com/layers/ocelot2/circleci-build/sdk9-nano2022-win.net9/images/sha256-37b718885f8cfb3480299f48044836f01aec2370e331667dd1811a4c94a4ce45?context=explore), uploaded on Dec 3, 2024. This Windows OS image contains .NET 9 SDK only. It supports builds for `net9.0` framework.

### Double SDKs Tags
- [sdk9-alpine-lin.net8-9](https://hub.docker.com/layers/ocelot2/circleci-build/sdk9-alpine-lin.net8-9/images/sha256-707924d144248178caff80578649f7d0e9b7c70ed51b6fb5171170c9a30a4eae?context=explore) aka [9.24.0](https://hub.docker.com/layers/ocelot2/circleci-build/9.24.0/images/sha256-707924d144248178caff80578649f7d0e9b7c70ed51b6fb5171170c9a30a4eae?context=explore), uploaded on Dec 3, 2023. This Linux OS image contains .NET 8 and 9 SDKs. It supports builds for `net8.0` and `net9.0` frameworks.
- [sdk9-nano2022-win.net8-9](https://hub.docker.com/layers/ocelot2/circleci-build/sdk9-nano2022-win.net8-9/images/sha256-6e44a8fc52ab091ea43090b6ab182f7a05d7ac31402ce742a7e035323e584cf7?context=explore) aka [9.24.win](https://hub.docker.com/layers/ocelot2/circleci-build/9.24.win/images/sha256-6e44a8fc52ab091ea43090b6ab182f7a05d7ac31402ce742a7e035323e584cf7?context=explore), uploaded on Dec 4, 2023. This Windows OS image contains .NET 8 and 9 SDKs. It supports builds for `net8.0` and `net9.0` frameworks.

### Links
- Docker Hub | [Microsoft dotnet Images](https://hub.docker.com/r/microsoft/dotnet)
- GitHub | dotnet-docker | [.NET SDK](https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md)
- StackOverflow | [PowerShell and process exit codes](https://stackoverflow.com/questions/57468522/powershell-and-process-exit-codes)
10 changes: 10 additions & 0 deletions docker/build-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version=9.24.win
tag=sdk9-nano2022-win.net8-9

docker build --no-cache --platform windows/amd64 -t ocelot2/circleci-build -f Dockerfile.windows .

docker tag ocelot2/circleci-build ocelot2/circleci-build:$tag
docker push ocelot2/circleci-build:$tag

docker tag ocelot2/circleci-build ocelot2/circleci-build:$version
docker push ocelot2/circleci-build:$version
17 changes: 9 additions & 8 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# This script builds the Ocelot Docker file
# echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin

# {DotNetSdkVer}.{OcelotVer} -> {.NET8}.{23.2} -> 8.23.2
version=8.23.2
docker build --platform linux/amd64 -t ocelot2/circleci-build -f Dockerfile.base .

echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
# {DotNetSdkVer}.{OcelotVer} -> {.NET9}.{24.0} -> 9.24.0
#version=9.24.0
tag=sdk9-alpine-lin.net8-9

docker tag ocelot2/circleci-build ocelot2/circleci-build:$version
docker push ocelot2/circleci-build:latest
docker push ocelot2/circleci-build:$version
docker build --platform linux/amd64 -t ocelot2/circleci-build -f Dockerfile.base .
docker tag ocelot2/circleci-build ocelot2/circleci-build:$tag
docker push ocelot2/circleci-build:$tag
# docker tag ocelot2/circleci-build ocelot2/circleci-build:$version
# docker push ocelot2/circleci-build:$version
File renamed without changes.
25 changes: 25 additions & 0 deletions docker/outdated/Dockerfile.8.23.2.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine

RUN apk add bash icu-libs krb5-libs libgcc libintl libssl3 libstdc++ zlib git openssh-client

RUN curl -L --output ./dotnet-install.sh https://dot.net/v1/dotnet-install.sh

RUN chmod u+x ./dotnet-install.sh

# Install .NET 8 SDK (already included in the base image, but listed for consistency)
RUN ./dotnet-install.sh -c 8.0 -i /usr/share/dotnet

# Install .NET 7 SDK
RUN ./dotnet-install.sh -c 7.0 -i /usr/share/dotnet

# Install .NET 6 SDK
RUN ./dotnet-install.sh -c 6.0 -i /usr/share/dotnet

# Generate and export the development certificate
RUN dotnet dev-certs https -ep /certs/cert.pem -p '' && \
chmod 644 /certs/cert.pem

ENV ASPNETCORE_URLS="https://+;http://+"
ENV ASPNETCORE_HTTPS_PORT=443
ENV ASPNETCORE_Kestrel__Certificates__Default__Password=""
ENV ASPNETCORE_Kestrel__Certificates__Default__Path=/certs/cert.pem
6 changes: 3 additions & 3 deletions samples/Administration/Issue645.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"id": "0f60e7b3-e4f1-4458-bbc4-fc4809e86b2d",
"type": "text/javascript",
"exec": [
string.Empty
""
]
}
},
Expand All @@ -142,9 +142,9 @@
"id": "1279a2cf-b771-4a86-9dfa-302b240fac62",
"type": "text/javascript",
"exec": [
string.Empty
""
]
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/Basic/Ocelot.Samples.Basic.ApiGateway.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<None Update="ocelot.json;appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Steeltoe.Discovery.Client" Version="1.1.0" />
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="3.2.8" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Web\Ocelot.Samples.Web.csproj" />
Expand Down
2 changes: 0 additions & 2 deletions samples/Eureka/DownstreamService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,5 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDeveloperExceptionPage();
}

app.UseDiscoveryClient();
}
}
8 changes: 3 additions & 5 deletions samples/GraphQL/Ocelot.Samples.GraphQL.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<None Update="ocelot.json;appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GraphQL" Version="4.8.0" />
<PackageReference Include="GraphQL" Version="8.2.1" />
<PackageReference Include="GraphQL.NewtonsoftJson" Version="8.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
Expand Down
Loading

0 comments on commit a80fe9d

Please sign in to comment.