-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (29 loc) · 768 Bytes
/
Dockerfile
File metadata and controls
34 lines (29 loc) · 768 Bytes
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
33
34
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
# restore solution packages
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS restore
WORKDIR /
COPY ["src/Netstr/Netstr.csproj", "src/Netstr/"]
COPY ["test/Netstr.Tests/Netstr.Tests.csproj", "test/Netstr.Tests/"]
COPY ["Netstr.sln", ""]
RUN dotnet restore
# build the main project
FROM restore AS build
COPY . .
WORKDIR "/src/Netstr"
RUN dotnet build -c Release -o /app/build
# run tests
FROM build AS test
WORKDIR "/test/Netstr.Tests"
RUN dotnet test -c Release
# publish
FROM test AS publish
WORKDIR "/src/Netstr"
RUN dotnet publish "Netstr.csproj" -c Release -o /app/publish
# final
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Netstr.dll"]