-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApiDockerfile
36 lines (35 loc) · 1.11 KB
/
ApiDockerfile
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
35
36
# FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
# WORKDIR /app
# # Copy csproj and restore as distinct layers
# COPY *.csproj ./
# RUN dotnet restore
# # Copy everything else and build
# COPY . ./
# RUN dotnet publish -c Release -o out
# # Build runtime image
# FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1803 AS base
# WORKDIR /app
# EXPOSE 80
# COPY --from=build /app/out ./
# ENTRYPOINT ["dotnet", "WebApiService.dll"]
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
# Copy csproj and restore as distinct layers
COPY ["WebApiService/WebApiService.csproj", "WebApiService/"]
COPY ["MyClassLibaray/MyClassLibaray.csproj", "MyClassLibaray/"]
RUN dotnet restore "WebApiService/WebApiService.csproj"
# Copy everything else and build
COPY . .
WORKDIR "/src/WebApiService"
RUN dotnet build "WebApiService.csproj" -c Release -o /app
# publish
FROM build AS publish
RUN dotnet publish "WebApiService.csproj" -c Release -o /app
# deploy
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WebApiService.dll"]