A full C# rewrite of Google's Jib, Fib.Net builds optimized Docker and OCI images from .NET projects without the need for a Dockerfile or docker daemon.
To start using Fib.Net to build images for your ASP.NET Core project, install the Fib.Net.MSBuild package.
dotnet install Fib.Net.MSBuild
Then just run a publish targeting the FibDotNet publish provider.
dotnet publish -p:PublishProvider=FibDotNet
This will default to publishing the resulting image to your local docker daemon. The repository name will be the same as your project, and will be tagged with your project version.
Fib.Net.MSBuild uses standard MSBuild Properties and Items to control its build. These can be set at the command line, or saved in either your project file, or an MSBuild publish profile.
The type of publish action being performed. Defaults to Daemon
when not explicitly set.
Valid values are:
Daemon
(default): Publishes the image to the local docker daemon using thedocker
command.Push
: Pushes the image to the remote registry.Tar
: Build a tar file of your image.
The path/name of the tar file to be written for publish type Tar
.
Defaults to $(OutputPath)$(PackageId).tar
The format of the image. Can be Docker or OCI.
Defaults to Docker
.
When true, sets the time metadata of the image to be Jan 1, 1970. This allows every build to have the same hash.
The base image the final image is built from. By default it is built from $(FibBaseRegistry)
,
$(FibBaseRepository)
, $(FibBaseTag)
and $(FibBaseDigest)
.
The registry of the base image. Defaults to mcr.microsoft.com
.
The base image repository. Defaults to dotnet/core/aspnet
.
The base image tag. Defaults to $(BundledNETCoreAppTargetFrameworkVersion)
.
Overridden by $(FibBaseDigest)
.
The hash/digest of the base image. Overrides FibBaseImage.
The name/full tag of the image being built.
If not set, built from $(FibTargetRegistry)
and $(FibTargetRepository)
.
The registry of the image being built. Defaults to '', which means the docker registry.
The repository of the image being built. Defaults to $(PackageId)
.
Semicolon separated list of tags to tag your image with.
Gets converted to FibTargetTag items.
Defaults to $(PackageVersion)
.
The image entrypoint. Defaults to dotnet
.
The image cmd. Defaults to the output assembly in the image.
The image working directory.
The image user.
The list of files to be added to the image. Fib.Net.MSBuild will take all the files in your publish directory and add them to the image in various layers.
FibImageFile items require two metadata properties:
- Layer: The layer the file is being added to. Fib.Net.MSBuild splits item types into separate layers to improve repeated build speed.
- TargetPath: The location in the image to put the file.
The environment variables to add to the image. They have the format <key>=<value>
.
The ports the image will expose by default.
Format can be any of port number (80
),
port/protocol (8080/tcp
) or port range/protocol (1000-3000/tcp
).
The volume mount points of the image.
The metadata labels to apply to the image. They have the format <key>=<value>
.