Skip to content

Instantly share code, notes, and snippets.

@robinmanuelthiel
Created November 19, 2018 16:50
Show Gist options
  • Save robinmanuelthiel/0509487f964bee8df3136fb6470a5c21 to your computer and use it in GitHub Desktop.
Save robinmanuelthiel/0509487f964bee8df3136fb6470a5c21 to your computer and use it in GitHub Desktop.
#######################################################
# Step 1: Build the application in a container #
#######################################################
# Download the official ASP.NET Core SDK image
# to build the project while creating the docker image
FROM microsoft/dotnet:2.1-sdk as build
WORKDIR /app
# Restore NuGet packages
COPY *.csproj .
RUN dotnet restore
# Copy the rest of the files over
COPY . .
# Build the application
RUN dotnet publish --output /out/ --configuration Release
#######################################################
# Step 2: Run the build outcome in a container #
#######################################################
# Download the official ASP.NET Core Runtime image
# to run the compiled application
FROM microsoft/dotnet:2.1-aspnetcore-runtime
WORKDIR /app
# Open HTTP and HTTPS ports
EXPOSE 80
EXPOSE 443
# Copy the build output from the SDK image
COPY --from=build /out .
# Start the application
ENTRYPOINT ["dotnet", "ContosoMaintenance.WebAPI.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment