forked from wilschok/cu-cicd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
32 lines (26 loc) · 999 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# build stage
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 as build-env
WORKDIR /app
# restore stage
# copy csproj files and restore packages - separate container layers
# starting from solution is also possible
COPY CICD.Lib/*.csproj ./CICD.Lib/
RUN dotnet restore ./CICD.Lib/*.csproj
COPY CICD.Test/*.csproj ./CICD.Test/
RUN dotnet restore ./CICD.Test/*.csproj
COPY CICD.Web/*.csproj ./CICD.Web/
RUN dotnet restore ./CICD.Web/*.csproj
# copy source code
COPY . .
ENV TEAMCITY_PROJECT_NAME = ${TEAMCITY_PROJECT_NAME} # visualize test results in Teamcity
# test stage
# run separate: cached layer if tests success
RUN dotnet test CICD.Test/CICD.Test.csproj --verbosity=normal
# build in release mode to folder publish
RUN dotnet publish CICD.Web/CICD.Web.csproj -c Release -o /publish
# runtime image stage
FROM mcr.microsoft.com/dotnet/core/sdk:2.2
# put release build-files in runtime image /publish
WORKDIR /publish
COPY --from=build-env /publish .
ENTRYPOINT [ "dotnet","CICD.Web.dll" ]