-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
32 lines (26 loc) · 893 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
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /source
# copy csproj and restore as distinct layer
COPY *.sln .
COPY src/TemplateService/*.csproj ./src/TemplateService/
COPY tests/TemplateService.Tests/*.csproj ./tests/TemplateService.Tests/
RUN dotnet restore
# copy everything else to build the app
COPY src/TemplateService/. ./src/TemplateService/
COPY tests/TemplateService.Tests/. ./tests/TemplateService.Tests/
WORKDIR /source/src/TemplateService
RUN dotnet build
# create a layer for unit tests
FROM build AS test
WORKDIR /source/tests/TemplateService.Tests
RUN dotnet test
# now create publish layer
FROM build AS publish
RUN dotnet publish -c Release -o /app --no-restore
# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
WORKDIR /app
COPY --from=publish /app ./
EXPOSE 80
ENV ASPNETCORE_URLS="http://+:80"
ENTRYPOINT ["dotnet", "TemplateService.dll"]