Skip to content

Instantly share code, notes, and snippets.

@joaopgrassi
Last active July 16, 2018 20:13
Show Gist options
  • Save joaopgrassi/3792a127952211dde5b420fd028f7852 to your computer and use it in GitHub Desktop.
Save joaopgrassi/3792a127952211dde5b420fd028f7852 to your computer and use it in GitHub Desktop.
Docker image that creates, builds and runs a simple .net core console app using multi-stage build
# A simple test using multi-stage builds in Docker to create a simple console app using dotnet core
# if only using the sdk, the image size is 1.7GB. Using multi-stage build the size is reduced to 180mb
FROM microsoft/dotnet:2.1-sdk AS build
## creates and builds the app
RUN dotnet new console -lang "c#" -n testapp
RUN cd testapp
WORKDIR /testapp/
RUN dotnet build -c Release -o output
# uses output from build step and runs the dll
FROM microsoft/dotnet:2.1-runtime AS runtime
COPY --from=build /testapp/output .
ENTRYPOINT ["dotnet", "testapp.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment