Skip to content

Commit

Permalink
Adding different build architectures (x64 & arm64) and using docker b…
Browse files Browse the repository at this point in the history
…uild to now publish nuget packages.
  • Loading branch information
kibblewhite committed Jul 29, 2022
1 parent 4608b4c commit 5f95d62
Show file tree
Hide file tree
Showing 18 changed files with 261 additions and 5 deletions.
42 changes: 42 additions & 0 deletions .output/linux-arm64/HashiVaultCs.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0/linux-arm64",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {},
".NETCoreApp,Version=v6.0/linux-arm64": {
"HashiVaultCs/1.1.1.3": {
"dependencies": {
"FormatWith": "3.0.1"
},
"runtime": {
"HashiVaultCs.dll": {}
}
},
"FormatWith/3.0.1": {
"runtime": {
"lib/netstandard2.0/FormatWith.dll": {
"assemblyVersion": "3.0.1.0",
"fileVersion": "3.0.1.0"
}
}
}
}
},
"libraries": {
"HashiVaultCs/1.1.1.3": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"FormatWith/3.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-qAgVI8A9l33ZoOS/16slW82YktWWezb4sx535lGqdHSPB3ULVKWg6BJ4oi3FltFjNiMa3bypqFdmoFFgHZxkdA==",
"path": "formatwith/3.0.1",
"hashPath": "formatwith.3.0.1.nupkg.sha512"
}
}
}
Binary file added .output/linux-arm64/HashiVaultCs.dll
Binary file not shown.
42 changes: 42 additions & 0 deletions .output/linux-x64/HashiVaultCs.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0/linux-x64",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {},
".NETCoreApp,Version=v6.0/linux-x64": {
"HashiVaultCs/1.1.1.3": {
"dependencies": {
"FormatWith": "3.0.1"
},
"runtime": {
"HashiVaultCs.dll": {}
}
},
"FormatWith/3.0.1": {
"runtime": {
"lib/netstandard2.0/FormatWith.dll": {
"assemblyVersion": "3.0.1.0",
"fileVersion": "3.0.1.0"
}
}
}
}
},
"libraries": {
"HashiVaultCs/1.1.1.3": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"FormatWith/3.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-qAgVI8A9l33ZoOS/16slW82YktWWezb4sx535lGqdHSPB3ULVKWg6BJ4oi3FltFjNiMa3bypqFdmoFFgHZxkdA==",
"path": "formatwith/3.0.1",
"hashPath": "formatwith.3.0.1.nupkg.sha512"
}
}
}
Binary file added .output/linux-x64/HashiVaultCs.dll
Binary file not shown.
42 changes: 42 additions & 0 deletions .output/win-arm64/HashiVaultCs.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0/win-arm64",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {},
".NETCoreApp,Version=v6.0/win-arm64": {
"HashiVaultCs/1.1.1.3": {
"dependencies": {
"FormatWith": "3.0.1"
},
"runtime": {
"HashiVaultCs.dll": {}
}
},
"FormatWith/3.0.1": {
"runtime": {
"lib/netstandard2.0/FormatWith.dll": {
"assemblyVersion": "3.0.1.0",
"fileVersion": "3.0.1.0"
}
}
}
}
},
"libraries": {
"HashiVaultCs/1.1.1.3": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"FormatWith/3.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-qAgVI8A9l33ZoOS/16slW82YktWWezb4sx535lGqdHSPB3ULVKWg6BJ4oi3FltFjNiMa3bypqFdmoFFgHZxkdA==",
"path": "formatwith/3.0.1",
"hashPath": "formatwith.3.0.1.nupkg.sha512"
}
}
}
Binary file added .output/win-arm64/HashiVaultCs.dll
Binary file not shown.
42 changes: 42 additions & 0 deletions .output/win-x64/HashiVaultCs.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0/win-x64",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {},
".NETCoreApp,Version=v6.0/win-x64": {
"HashiVaultCs/1.1.1.3": {
"dependencies": {
"FormatWith": "3.0.1"
},
"runtime": {
"HashiVaultCs.dll": {}
}
},
"FormatWith/3.0.1": {
"runtime": {
"lib/netstandard2.0/FormatWith.dll": {
"assemblyVersion": "3.0.1.0",
"fileVersion": "3.0.1.0"
}
}
}
}
},
"libraries": {
"HashiVaultCs/1.1.1.3": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"FormatWith/3.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-qAgVI8A9l33ZoOS/16slW82YktWWezb4sx535lGqdHSPB3ULVKWg6BJ4oi3FltFjNiMa3bypqFdmoFFgHZxkdA==",
"path": "formatwith/3.0.1",
"hashPath": "formatwith.3.0.1.nupkg.sha512"
}
}
}
Binary file added .output/win-x64/HashiVaultCs.dll
Binary file not shown.
18 changes: 14 additions & 4 deletions Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@
<Nullable>enable</Nullable>
<AssemblyName>HashiVaultCs</AssemblyName>
<RootNamespace>HashiVaultCs</RootNamespace>
<Version>1.1.1.3</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.1.1.4</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>kibblewhite &lt;kibblewhite@live.com&gt;</Authors>
<Description>A .NET library for interacting with HashiCorp Vault. Features are minimal, please read documentation.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>csharp-vault-hashicorp.png</PackageIcon>
<RepositoryUrl>https://github.com/kibblewhite/HashiVaultCs</RepositoryUrl>
<PackageTags>HashiCorp;Vault;</PackageTags>
<AssemblyVersion>1.1.1.3</AssemblyVersion>
<FileVersion>1.1.1.3</FileVersion>
<AssemblyVersion>1.1.1.4</AssemblyVersion>
<FileVersion>1.1.1.4</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<ApplicationIcon>csharp-vault-hashicorp.ico</ApplicationIcon>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>True</Optimize>
</PropertyGroup>

<ItemGroup>
Expand Down
Binary file added Client/csharp-vault-hashicorp.ico
Binary file not shown.
Binary file added Client/csharp-vault-hashicorp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Dockerfile.build.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Build: docker build --no-cache -t hashivaultcs:dev-arm64 --file Dockerfile.build.arm64 .
## Once the image is built, get the list of avaiable images in the local docker registry: docker image ls
## Run the following command with corresponding the image id: docker run --name hashivaultcs-dev-arm64 -td <image-id />
## This will run an empry container (nothing will happen) - you can connect and grab the files from it

FROM mcr.microsoft.com/dotnet/runtime:6.0-focal-arm64v8 AS base-arm64
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0-focal-arm64v8 AS build-arm64
WORKDIR /src-arm64

COPY ["Client/Client.csproj", "Client/"]
RUN dotnet restore "Client/Client.csproj"
COPY . .

WORKDIR "/src-arm64/Client"
RUN dotnet build "Client.csproj" --os linux -a arm64 -c Release -o /app/build-arm64/bin/Release/net6.0/linux-arm64
RUN dotnet build "Client.csproj" --os win -a arm64 -c Release -o /app/build-arm64/bin/Release/net6.0/win-arm64

FROM build-arm64 AS publish-arm64
RUN dotnet publish "Client.csproj" --os linux -a arm64 -c Release -o /app/publish-arm64/bin/Release/net6.0/linux-arm64
RUN dotnet publish "Client.csproj" --os win -a arm64 -c Release -o /app/publish-arm64/bin/Release/net6.0/win-arm64

FROM base-arm64 AS final-arm64
WORKDIR /app
COPY --from=publish-arm64 /app/publish-arm64/bin/Release ./runtime/arm64/
26 changes: 26 additions & 0 deletions Dockerfile.build.x64
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Build: docker build --no-cache -t hashivaultcs:dev-x64 --file Dockerfile.build.x64 .
## Once the image is built, get the list of avaiable images in the local docker registry: docker image ls
## Run the following command with corresponding the image id: docker run --name hashivaultcs-dev-x64 -td <image-id />
## This will run an empry container (nothing will happen) - you can connect and grab the files from it

FROM mcr.microsoft.com/dotnet/runtime:6.0-focal-amd64 AS base-x64
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0-focal-amd64 AS build-x64
WORKDIR /src-x64

COPY ["Client/Client.csproj", "Client/"]
RUN dotnet restore "Client/Client.csproj"
COPY . .

WORKDIR "/src-x64/Client"
RUN dotnet build "Client.csproj" --os linux -a x64 -c Release -o /app/build-x64/bin/Release/net6.0/linux-x64
RUN dotnet build "Client.csproj" --os win -a x64 -c Release -o /app/build-x64/bin/Release/net6.0/win-x64

FROM build-x64 AS publish-x64
RUN dotnet publish "Client.csproj" --os linux -a x64 -c Release -o /app/publish-x64/bin/Release/net6.0/linux-x64
RUN dotnet publish "Client.csproj" --os win -a x64 -c Release -o /app/publish-x64/bin/Release/net6.0/win-x64

FROM base-x64 AS final-x64
WORKDIR /app
COPY --from=publish-x64 /app/publish-x64/bin/Release ./runtime/x64/
19 changes: 19 additions & 0 deletions Dockerfile.nuget.publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Build: docker build --no-cache --build-arg NUGET_KEY=<replace-nuget-api-key-here /> --build-arg NUGET_URL=https://api.nuget.org/v3/index.json --file Dockerfile.nuget.publish .
## This will publish the Client project to the public nuget registry

FROM mcr.microsoft.com/dotnet/runtime:6.0-focal-amd64 AS base-x64
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0-focal-amd64 AS build-x64
ARG NUGET_KEY
ARG NUGET_URL
WORKDIR /src-x64

COPY ["Client/Client.csproj", "Client/"]
RUN dotnet restore "Client/Client.csproj"
COPY . .

WORKDIR "/src-x64/Client"
RUN dotnet build "Client.csproj" -c Release -o /app/build-x64/bin/Release/net6.0
RUN dotnet pack "Client.csproj" -c Release -o /app/build-x64/bin/Release/net6.0/publish
RUN dotnet nuget push /app/build-x64/bin/Release/net6.0/publish/HashiVaultCs.*.nupkg -s $NUGET_URL -k $NUGET_KEY
5 changes: 4 additions & 1 deletion HashiVaultCs.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csp
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FBCC82E1-EE2D-40D2-BD57-270645F1B78A}"
ProjectSection(SolutionItems) = preProject
csharp-vault-hashicorp.ico = csharp-vault-hashicorp.ico
csharp-vault-hashicorp.png = csharp-vault-hashicorp.png
Dockerfile.build.arm64 = Dockerfile.build.arm64
Dockerfile.nuget.publish = Dockerfile.nuget.publish
LICENSE = LICENSE
Dockerfile.build.x64 = Dockerfile.build.x64
README.md = README.md
EndProjectSection
EndProject
Expand Down Expand Up @@ -62,7 +66,6 @@ Global
{DBBEEF2D-A83C-4D94-A3D2-16E41352EBB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DBBEEF2D-A83C-4D94-A3D2-16E41352EBB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DBBEEF2D-A83C-4D94-A3D2-16E41352EBB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DBBEEF2D-A83C-4D94-A3D2-16E41352EBB1}.Release|Any CPU.Build.0 = Release|Any CPU
{45A81E28-0CE6-4313-BA86-0D816F986BD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45A81E28-0CE6-4313-BA86-0D816F986BD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45A81E28-0CE6-4313-BA86-0D816F986BD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ I took inspiration from this article to get me started: https://www.infoq.com/ar

##### What's next...
- Adding ARM64 support - timing this after Visual Studio 17.3 preview/rc release (and some of the issues have been ironed out)
- In the `.output` directory I generated a bunch of assemblies for win and linux x64 and arm64 platforms (the build process in documented using the Dockerfiles)
- There appears to little to no difference between the assembly files (loaded them into hexcmp) which leads me to believe under these conditions there is no need to generate both x64 and arm64 binaries for the nuget packages.
- I would like to add some basic reading of PKI secrets and getting certificates into my applications next.
- After that I would like to add the [Wrapping Token concept](https://www.vaultproject.io/docs/concepts/response-wrapping).

Expand Down Expand Up @@ -354,5 +356,7 @@ curl --header "X-Vault-Token: hvs.CAESILacrRZCXR-e1GTcitvww7EdFdq7C4ftIRDro6lkE3

This is here just to remind me of how to publish to nuget:
```bash
dotnet build -c Release
dotnet pack -c Release -o Client\bin\Release\net6.0\publish
dotnet nuget push Client\bin\Release\net6.0\publish\HashiVaultCs.*.nupkg -k [api-key-here /] -s https://api.nuget.org/v3/index.json
```
Binary file added csharp-vault-hashicorp.ico
Binary file not shown.
Binary file modified csharp-vault-hashicorp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5f95d62

Please sign in to comment.