This repository contains images that are used to compile/publish ASP.NET Core applications inside the container. This is different to compiling an ASP.NET Core application and then adding the compiled output to an image, which is what you would do when using the microsoft/aspnetcore image. These Dockerfiles use the microsoft/dotnet image as its base.
1.1.1, 1.1, latest (Dockerfile)1.0.4, 1.0, lts (Dockerfile)1.0-1.1-2017-03, 1.0-1.1 (designed for CI builds), (Dockerfile)ASP.NET Core is a new open-source and cross-platform framework for building modern cloud based internet connected applications, such as web apps, IoT apps and mobile backends. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions. You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac and Linux. ASP.NET Core is open source at GitHub.
This image contains:
The CI Image (1.0-1.1) contains both the 1.0 and 1.1 pre-restored packages. It is intended for when you have a solution containing both 1.1.x and 1.0.x projects and want to build them all in the same container, gaining advantage of the pre-restored packages. Because it has an extra set of packages it is bigger than the other, more focused, images.
docker runYou can use this container to compile your application when it runs. If you use the Visual Studio tooling to setup CI/CD to Azure Container Service then this method of using the build container is used.
Run the build container, mounting your code and output directory, and publish your app:
docker run -it -v $(PWD):/app --workdir /app microsoft/aspnetcore-build bash -c "dotnet restore && dotnet publish -c Release -o ./bin/Release/PublishOutput"
After this has run the application in the current directory will be published to the bin/Release/PublishOutput directory.
docker buildWith this technique your application is compiled when you run docker build and you then copy the binaries out of the built image.
Create a Dockerfile to build your application (Dockerfile.build is a common name used).
FROM microsoft/aspnetcore-build
WORKDIR /app
COPY *.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish --output /out/ --configuration Release
Build your image:
$ docker build -t build-image -f Dockerfile.build
Create a container from your image and copy your built application out.
$ docker create --name build-cont build-image
$ docker cp build-cont:/out ./bin/Release/PublishOutput
After this the application in the current directory will be published to the bin/Release/PublishOutput directory.
From here you could construct an optimized runtime image with the microsoft/aspnetcore image or just deploy/run the binaries as normal without using Docker at runtime.
This approach has the advantage of caching the results of dotnet restore so that packages are not downloaded unless you change your project file.
docker pull ostusa/aspnetcore-build:latest