A simple CLI tool to dockerize ASP.NET Core application
Install module globally
npm i -g dockerize-aspnetcore
cd /path/to/app
dockerize-aspnetcore <WEB_PROJECT_NAME>
where <WEB_PROJECT_NAME>
(e.g. MyApp.Web
) is a name of a folder with asp.net core project in your solution.
As a result, you'll see ready-to-use Dockerfile
and .dockerignore
files in your web project folder.
If you are against global installation, you can install it locally:
cd /path/to/app/frontend/folder
npm i dockerize-aspnetcore
cd /back/to/app
npx dockerize-aspnetcore <WEB_PROJECT_NAME>
The global installation is still recommended as your source code doesn't have to know about this module - the Dockerfile is enough.
It is assumed that your app was created using the standard dotnet new
syntax.
If your app is SPA - it's also supported.
Please check Dockerfile (line 2) for details - npm
installation is already in place.
The implementation is pretty simple there - Docker build process relies on dotnet publish
command, which does all the needed stuff.
It's reasonable - as both Angular- and React-based asp.net core templates come up with such configuration out-of-the-box.
If you have a bit more complex setup with your frontend and backend apps - please take a look on the Multi-Stage Docker builds