Skip to content

ddieruf/pack-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pack-csharp

A .NET (c#) wrapper library for the Cloud Native Buildpacks pack cli v0.19.0.

Whats going on

I borrowed the ideas of a process runner from the dotnet watch command and simplified a bit. I also embedded a specific version of the pack cli within the package (which is why it's ~40mb) for linux, macos, and windows. During construction the correct binary is reconstructed locally for the given OS. Then when either the pack, inspect, or version method is run a process spec is built and run in the background using a runner. The output is fed back as a collection of lines for logging.

Get started

Add the nuget distributed package to your project.

dotnet add package pack-csharp

Initialize the constructor

using pack-csharp

var logger = new LoggerFactory().CreateLogger<Pack>();
const bool quiet = false;
const bool verbose = true;
const bool timeStamps = true;

var pack = new Pack(logger, quiet, verbose, timeStamps);

Create an artifact to be containerized

dotnet publish my-project -o "c:\pub"

# optionally you could zip it up and provide the full path to zip
# Compress-Archive -Path "c:\pub" -DestinationPath "c:\artifact.zip"

(make sure docker is running)

Build the container image

var cts = new CancellationTokenSource();
var output = await pack.Build("some-repo/my-image", "paketobuildpacks/builder:base", "c:\pub", cts.Token);
logger.LogInformation(string.Join(Environment.NewLine, output));

Inspect the resulting image

var inspection = await pack.Inspect("some-repo/my-image");
logger.LogInformation(inspection));

Options

When running pack.Build you can optionally provide a PackBuildSpec. This offers all kinds of options to manipulate and configure the image and build environment.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages