Giter Site home page Giter Site logo

codefork / dockerize.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brthor/dockerize.net

0.0 2.0 0.0 29 KB

.NET Cli Tool to package your .NET Core Application into a docker image: 'dotnet dockerize'

License: MIT License

C# 96.92% Shell 3.08%

dockerize.net's Introduction

Dockerize.NET: Your .NET Core App to a docker image

Build Status Nuget Version Number

dotnet dockerize -t brthor/serviceWorker:dev

This is a simple dotnet cli tool that enables you to easily package your dotnet app into a docker container. The above invocation creates a docker image with the tag brthor/serviceWorker:dev which you can then docker push to your registry or docker run locally.

The image simply runs the static void Main(string[] args) or other entrypoint of your app.

This has many uses:

  • Getting a service image ready for kubernetes environment
  • Testing your application in different OS's available in docker
  • Isolated environments for your app.

Installation

It's easy, add the following to your *.csproj file:

<ItemGroup>
  <DotNetCliToolReference Include="Brthor.Dockerize.NET" Version="1.0.0-*" />
</ItemGroup>

Then dotnet restore, followed by dotnet dockerize to make your docker image. The default tag is the project name.

Options

See dotnet dockerize -h for available options.

$ dotnet dockerize -h

Usage:  [options]

Options:
  -t |--tag <tag>      The desired tag name of the created image. Will be directly passed to docker build -t, see docker build --help for more info. Defaults to the project name.

  -r |--runtime <RID>  The RID of the specified Base Docker image. Defaults to "linux-x64".

  -i |--image <image>  The base docker image used for the generated docker file. If you change this from the default, be sure toupdate BaseRid if appropriate. Defaults to "microsoft/dotnet:2.0-runtime".

  -? | -h | --help     Show help information

Example

$ mkdir newApp
$ cd newApp
$ dotnet new console
The template "Console Application" was created successfully.

... etc output...

At this point you need to edit newApp.csproj and add the tool reference from above, and the whole file will look like:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Brthor.Dockerize.NET" Version="1.0.0-*" />
  </ItemGroup>
</Project>

Continuing on the command line:

$ dotnet dockerize
Dockerize Config
Base Docker Image: microsoft/dotnet:2.0-runtime
Base Rid of Docker Image: linux-x64
Tag: newApp

... etc output...

$ docker run -it newApp
Hello World!

Contributing

There's a lot of room for improvement, especially with customization of the underlying dockerfile. Feel free to create pull requests for additional features.

dockerize.net's People

Contributors

brthor avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.