forked from Sharan144/awscloudbuilders-containerise-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
27 lines (21 loc) · 821 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
# FROM sets the base image as sdk:3.1 from microsoft
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
# Sets the working directory for commands like RUN , ENTRYPOINT and COPY
WORKDIR /source
# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore -r linux-x64
# copy everything else to build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
# Build the application to the /app folder
RUN dotnet publish -c release -o /app -r linux-x64 --self-contained false --no-restore
# final stage/image
# 3.1-bionic used for Ubuntu 18.04
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic
WORKDIR /app
# Copy artifacts from the previous docker build
COPY --from=build /app ./
ENTRYPOINT ["./aspnetapp"]