2019-12-26 18:23:25 +03:00
|
|
|
# Multi-stage Docker build, test and package
|
|
|
|
# Based on https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/dotnet-docker-unit-testing.md
|
|
|
|
|
|
|
|
ARG DOTNET_VERSION=3.0
|
|
|
|
|
|
|
|
FROM mcr.microsoft.com/dotnet/core/sdk:$DOTNET_VERSION AS build
|
2019-10-28 12:49:16 +03:00
|
|
|
WORKDIR /app
|
|
|
|
|
2019-12-26 18:23:25 +03:00
|
|
|
# Copy csproj and restore as distinct layers. This caches a Docker layer with downloaded
|
|
|
|
# dependencies, making the next build faster if only code files have been changed.
|
2019-10-28 12:49:16 +03:00
|
|
|
COPY K2Bridge/*.csproj ./
|
|
|
|
RUN dotnet restore
|
|
|
|
|
|
|
|
# Copy everything else and build
|
2019-12-26 18:23:25 +03:00
|
|
|
COPY . ./
|
|
|
|
RUN dotnet publish K2Bridge -c Release -o out
|
|
|
|
|
|
|
|
# Run tests
|
|
|
|
RUN dotnet test K2Bridge.Tests.UnitTests "--logger:trx;LogFileName=/app/TestResult.xml"
|
2019-10-28 12:49:16 +03:00
|
|
|
|
|
|
|
# Build runtime image
|
2019-12-26 18:23:25 +03:00
|
|
|
|
|
|
|
FROM mcr.microsoft.com/dotnet/core/aspnet:$DOTNET_VERSION AS runtime
|
2019-10-28 12:49:16 +03:00
|
|
|
WORKDIR /app
|
2019-12-26 18:23:25 +03:00
|
|
|
COPY --from=build /app/out .
|
2019-10-28 12:49:16 +03:00
|
|
|
ENTRYPOINT ["dotnet", "K2Bridge.dll"]
|