dockgen 0.3.0

dotnet tool install --global dockgen --version 0.3.0                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local dockgen --version 0.3.0                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dockgen&version=0.3.0                
nuke :add-package dockgen --version 0.3.0                

Bugs Reliability Rating Technical Debt Maintainability Rating Vulnerabilities

dock-gen

dock-gen is a very simple .NET tool designed to generate Dockerfiles for one or multiple projects in a solution based on dependencies in a predictable way each time.

Please note, dock-gen is still in its early stages, some features may not be stable.

Since .NET 7, dotnet comes with a built-in feature to publish app as container image. If you don't need to generate Dockerfiles, you can use the dotnet publish command to publish your application as container. For more information, see the official documentation. dock-gen is designed to provide more control over the Dockerfile generation process but it may not be suitable for all use cases.

Installation

To install dock-gen, you can use the dotnet tool install command:

  1. global installation:
dotnet tool install --global dockgen
  1. local installation: (optional) if you don't have a manifest file for your project, create one:
dotnet new tool-manifest

Add the tool to the manifest file:

dotnet tool install dockgen

Usage

You can use dock-gen with the generate command. This command takes two optional parameters:

  • -s or --solution: To specify an absolute path to a solution file.
  • -p or --project: To specify an absolute path to a project file.

Here is an example of how to use the generate command:

dotnet dockgen generate -s C:\\repos\MySolution\MySolution.sln -p C:\\repos\MySolution\MyProject\MyProject.csproj

If no solution or project file is specified, dock-gen will try to find a solution file in the current directory.

Features

  • Generate Dockerfile: Generate a Dockerfile for a single or multiple projects at once
  • Multi-Stage Build: Generate a multi-stage Dockerfile for a project
  • Central Package/Build Management: dock-gen supports CPM/CBM in your project

Supported properties

Description for MSBuild properties can be found here: Official .NET docs

Property Description MSBuild Property Custom Property Default Value
ContainerBaseImage* ✔ yes ✘ no mcr.microsoft.com:443/dotnet/aspnet:8.0
ContainerRegistry Registry of the base image ✔ yes ✘ no mcr.microsoft.com
ContainerRepository Repository of the base image ✔ yes ✘ no dotnet/aspnet
ContainerFamily Family of the base image ✔ yes ✘ no
ContainerImageTag Tag of the base image ✔ yes ✘ no 8.0
ContainerBasePort Port of the base image ✘ no ✔ yes 443
ContainerPort Port(s) to expose in Dockerfile ✔ yes ✘ no
ContainerBuildImage Build image for the project ✘ no ✔ yes mcr.microsoft.com:443/dotnet/sdk:8.0
ContainerBuildRegistry Registry of the build image ✘ no ✔ yes mcr.microsoft.com
ContainerBuildRepository Repository of the build image ✘ no ✔ yes dotnet/sdk
ContainerBuildFamily Family of the build image ✘ no ✔ yes
ContainerBuildImageTag Tag of the build image ✘ no ✔ yes 8.0
ContainerBuildPort Port of the build image ✘ no ✔ yes 443

Roadmap

  • Support more advanced Dockerfile customizations

Contributing

We welcome contributions to dock-gen!

License

dock-gen is open source software licensed under the MIT. See the LICENSE file for more details.

Contact

If you have any questions or feedback, please feel free to create an issue.

Acknowledgements

This project makes use of the following open source projects:

  • Buildalyzer: A utility for performing design-time builds of .NET projects to obtain information such as package references and compiler flags.
  • Serilog: Simple .NET logging with fully-structured events.
  • .NET: .NET platform
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.3.0 92 10/21/2024
0.2.1 152 5/12/2024
0.2.0 84 5/3/2024
0.1.0 117 4/30/2024