Skip to content

Commit

Permalink
Update Docker and NuGet Tools to .NET 8 (#384)
Browse files Browse the repository at this point in the history
* Update Docker to .NET 8

* Update JRE version and target compilation

* Update tools

* Retargeting KNetPS

* masesgroup/JNet#334 moves JVM path into environment variable, so it is no more needed it in command-line

* #382 (comment): update Dockerfile(s)
  • Loading branch information
masesdevelopers authored May 15, 2024
1 parent 2435dad commit 6aa6784
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- name: Create Jars
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- name: Create Jars
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ jobs:

- name: Maven preparation (step 1)
if: matrix.language == 'java'
run: dotnet build --no-incremental --configuration Release --framework net6.0 /p:Platform="Any CPU" /p:NoWarn="0108%3B1030%3B0618" ./src/net/KNet.sln
run: dotnet build --no-incremental --configuration Release --framework net8.0 /p:Platform="Any CPU" /p:NoWarn="0108%3B1030%3B0618" ./src/net/KNet.sln

- name: Maven preparation (step 2)
if: matrix.language == 'java'
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- if: matrix.language == 'java'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- name: Create Jars
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- name: Create Jars
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generateclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- name: Create Jars
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pullrequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- name: Create Jars
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- name: Create Jars
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net6.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
run: mvn install:install-file -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.5.13 -Dpackaging=jar -Dfile=../../../bin/net8.0/JCOBridge.jar -f ./src/jvm/knet/pom.xml
shell: bash

- name: Create Jars
Expand Down
15 changes: 9 additions & 6 deletions src/container/DockerfileKNet.linux
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build-env
ARG TARGETARCH
WORKDIR /app

# Copy everything
COPY ./src/net ./
ENV KNET_DOCKER_BUILD_ACTIONS=true
# Restore as distinct layers
RUN dotnet restore KNetDocker.sln
RUN dotnet restore KNetDocker.sln -a $TARGETARCH
# Build and publish a release
RUN dotnet publish ./KNetCLI/KNetCLI.csproj --framework net6.0 -c Release -o out
RUN dotnet publish ./KNetCLI/KNetCLI.csproj --framework net8.0 -c Release -o out -a $TARGETARCH

# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:6.0-jammy
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime:8.0-jammy

# Add JRE
RUN apt update
RUN apt install -y openjdk-11-jre-headless
RUN apt-get update && apt-get install -y --no-install-recommends openjdk-17-jre-headless && rm -rf /var/lib/apt/lists/*

ADD ./jars /app/jars
ADD ./src/config /app/config

ENV JCOBRIDGE_JVMPath=/usr/lib/jvm/java-17-openjdk-amd64/lib/server/libjvm.so
ENV JCOBRIDGE_LicensePath=

WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "MASES.KNetCLI.dll"]
15 changes: 9 additions & 6 deletions src/container/DockerfileKNetConnect.linux
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build-env
ARG TARGETARCH
WORKDIR /app

# Copy everything
COPY ./src/net ./
ENV KNET_DOCKER_BUILD_ACTIONS=true
# Restore as distinct layers
RUN dotnet restore KNetDocker.sln
RUN dotnet restore KNetDocker.sln -a $TARGETARCH
# Build and publish a release
RUN dotnet publish ./KNetConnect/KNetConnect.csproj --framework net6.0 -c Release -o out
RUN dotnet publish ./KNetConnect/KNetConnect.csproj --framework net8.0 -c Release -o out -a $TARGETARCH

# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:6.0-jammy
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime:8.0-jammy

# Add JRE
RUN apt update
RUN apt install -y openjdk-11-jre-headless
RUN apt-get update && apt-get install -y --no-install-recommends openjdk-17-jre-headless && rm -rf /var/lib/apt/lists/*

ADD ./jars /app/jars
ADD ./src/config /app/config

ENV JCOBRIDGE_JVMPath=/usr/lib/jvm/java-17-openjdk-amd64/lib/server/libjvm.so
ENV JCOBRIDGE_LicensePath=

WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "MASES.KNetConnect.dll"]
2 changes: 1 addition & 1 deletion src/jvm/knet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<kafkaVersion>3.7.0</kafkaVersion>
<knetVersion>2.6.1.0</knetVersion>
<jcobridgeVersion>2.5.13</jcobridgeVersion>
<jcobridgepath>../../../bin/net6.0/JCOBridge.jar</jcobridgepath>
<jcobridgepath>../../../bin/net8.0/JCOBridge.jar</jcobridgepath>
</properties>
<distributionManagement>
<snapshotRepository>
Expand Down
2 changes: 1 addition & 1 deletion src/net/Common/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(KNET_DOCKER_BUILD_ACTIONS)' == 'true'">
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup Condition="'$(KNET_DOCKER_BUILD_ACTIONS)' != 'true'">
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="" />
Expand Down
4 changes: 2 additions & 2 deletions src/net/KNetCLI/KNetCLI.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<copyright>Copyright © MASES s.r.l. 2024</copyright>
<license type="file">LICENSE</license>
<icon>JCOB128x128.png</icon>
<tags>knet cli kafka apache-kafka dotnet clr netcore net6 kafka connect streams producer consumer providers streamprovider gateway</tags>
<tags>knet cli kafka apache-kafka dotnet clr netcore net8 kafka connect streams producer consumer providers streamprovider gateway</tags>
<packageTypes>
<packageType name="DotnetTool" />
</packageTypes>
Expand All @@ -24,6 +24,6 @@
<file src="..\..\..\LICENSE" target="LICENSE" />
<file src="..\Common\JCOB128x128.png" target="" />
<file src="..\..\documentation\articles\usageCLI.md" target="" />
<file src="..\..\..\binCLI\net6.0\" target="tools\net6.0\any\" />
<file src="..\..\..\binCLI\net8.0\" target="tools\net8.0\any\" />
</files>
</package>
4 changes: 2 additions & 2 deletions src/net/KNetConnect/KNetConnect.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<copyright>Copyright © MASES s.r.l. 2024</copyright>
<license type="file">LICENSE</license>
<icon>JCOB128x128.png</icon>
<tags>knet cli kafka apache-kafka dotnet clr netcore net6 kafka connect streams producer consumer providers streamprovider gateway</tags>
<tags>knet cli kafka apache-kafka dotnet clr netcore net8 kafka connect streams producer consumer providers streamprovider gateway</tags>
<packageTypes>
<packageType name="DotnetTool" />
</packageTypes>
Expand All @@ -24,6 +24,6 @@
<file src="..\..\..\LICENSE" target="LICENSE" />
<file src="..\Common\JCOB128x128.png" target="" />
<file src="..\..\documentation\articles\usageConnect.md" target="" />
<file src="..\..\..\binConnect\net6.0\" target="tools\net6.0\any\" />
<file src="..\..\..\binConnect\net8.0\" target="tools\net8.0\any\" />
</files>
</package>
6 changes: 3 additions & 3 deletions src/net/KNetPS/KNetPS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<Description>PowerShell command line interface of .NET suite for Apache Kafka. KNet is a comprehensive .NET suite for Apache Kafka providing all features: Producer, Consumer, Admin, Streams, Connect, backends (ZooKeeper and Kafka).</Description>
<Product>KNetPS</Product>
<OutputPath>..\..\..\MASES.KNetPS\</OutputPath>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<RunAnalyzersDuringLiveAnalysis>False</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzersDuringBuild>False</RunAnalyzersDuringBuild>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<OutputType>Exe</OutputType>
</PropertyGroup>

Expand Down Expand Up @@ -56,7 +56,7 @@
<None Update="MASES.KNetPSFramework.psd1" Condition="'$(TargetFramework)' == 'net462'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="MASES.KNetPSCore.psd1" Condition="'$(TargetFramework)' == 'net6.0'">
<None Update="MASES.KNetPSCore.psd1" Condition="'$(TargetFramework)' == 'net8.0'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/net/KNetPS/MASES.KNetPS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $binaryModuleRoot = $PSModuleRoot

if (($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop')) {
$binaryModuleFileName = 'MASES.KNetPSCore.psd1'
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'net6.0'
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'net8.0'
}
else {
$binaryModuleFileName = 'MASES.KNetPSFramework.psd1'
Expand Down

0 comments on commit 6aa6784

Please sign in to comment.