Skip to content

Instantly share code, notes, and snippets.

@wmaryszczak
Last active October 11, 2022 08:40
Show Gist options
  • Save wmaryszczak/555a7f02f7c53cf189333b5d8e2620a9 to your computer and use it in GitHub Desktop.
Save wmaryszczak/555a7f02f7c53cf189333b5d8e2620a9 to your computer and use it in GitHub Desktop.
dotnet tools in dockerfile
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build-env
WORKDIR /app

#Copy Source cpde files
COPY . ./
# Restore
RUN dotnet restore --ignore-failed-sources ./src/Cyberlogic.Hermes.WebApi/*proj
# Publish
RUN dotnet publish ./src/Cyberlogic.Hermes.WebApi/*proj -c Release -o ./publish --no-restore

RUN dotnet tool install --global dotnet-gcdump

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:5.0-focal
WORKDIR /app
RUN mkdir -p /root/.dotnet/tools/
COPY --from=build-env /app/publish/ .
COPY --from=build-env /root/.dotnet/tools/ /root/.dotnet/tools/
ENV PATH="/root/.dotnet/tools:${PATH}"
ENV TZ=Europe/Warsaw
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ENTRYPOINT ["dotnet", "Cyberlogic.Hermes.WebApi.dll", "--no-launch-profile"]
./dotnet-dump collect --process-id 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment