Skip to content

Instantly share code, notes, and snippets.

@nickcoad
Created June 13, 2019 08:25
Show Gist options
  • Save nickcoad/e5b8586a0815a151be00d313f3b2d998 to your computer and use it in GitHub Desktop.
Save nickcoad/e5b8586a0815a151be00d313f3b2d998 to your computer and use it in GitHub Desktop.
Cacheable restores dotnet core
FROM microsoft/dotnet:2.2-sdk AS restore
WORKDIR /tmp/build
COPY ./*.sln .
COPY ./*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p ${file%.*}/ && mv $file ${file%.*}/; done
RUN dotnet restore
# Copy in the source files
FROM restore AS build
WORKDIR /tmp/build
COPY . .
RUN dotnet publish -o output MyApp/MyApp.csproj
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /tmp/build/MyApp/output .
ENTRYPOINT [ "dotnet", "MyApp.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment