Skip to content

Commit

Permalink
Cleanup the Dockerfile and slim-down container using .dockerignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Wolfsteiner committed Aug 9, 2020
1 parent 7876d7a commit 551ea7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
.github/
art/
bin/
node_modules/
Expand Down
18 changes: 10 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /source
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.csproj ./
COPY WhatTheFuckShouldLukasHaveForLunch.csproj ./
RUN dotnet restore

# copy everything else and build app
COPY . ./
WORKDIR /source
RUN dotnet publish -c Release -o /app --no-restore
COPY . .

# publish
RUN dotnet publish -c Release -o out

# final stage/image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build /app .
CMD ASPNETCORE_URLS=http://*:$PORT dotnet WhatTheFuckShouldLukasHaveForLunch.dll

COPY --from=build-env /app/out .
ENTRYPOINT [ "dotnet", "WhatTheFuckShouldLukasHaveForLunch.dll" ]

0 comments on commit 551ea7e

Please sign in to comment.