Skip to content

Instantly share code, notes, and snippets.

@jeremymeng
Created March 1, 2019 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremymeng/a9a610bc108ae3fe57c90fa973187082 to your computer and use it in GitHub Desktop.
Save jeremymeng/a9a610bc108ae3fe57c90fa973187082 to your computer and use it in GitHub Desktop.
Dockerfile for application and sidecar
FROM microsoft/dotnet:2.2-sdk AS builder
WORKDIR /build
COPY *.csproj .
# Restore with `-r linux-x64` to download the runtime package containing crossgen.
RUN dotnet restore -r linux-x64
RUN cp `find ~/.nuget/packages -name crossgen` .
# Restore without `-r` option so that the shared runtime will be used to run the app.
RUN dotnet restore
COPY . .
RUN dotnet publish -c release -o out
FROM microsoft/dotnet:2.2-aspnetcore-runtime as application
# COMPlus_PerfMapEnabled is set in order to resolve symbols for .NET code.
ENV COMPlus_PerfMapEnabled=1
WORKDIR /app
COPY --from=builder /build/out /build/crossgen ./
ENTRYPOINT ["dotnet", "webapi.dll"]
FROM application as sidecar
# Add whatever tools you want here
RUN apt-get update \
&& apt-get install -y \
binutils \
curl \
htop \
procps \
liblttng-ust-dev \
linux-tools \
lttng-tools \
zip \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tools
RUN curl -OL http://aka.ms/perfcollect \
&& chmod a+x perfcollect
# perfcollect expects to find crossgen along side libcoreclr.so
RUN cp /app/crossgen $(dirname `find /usr/share/dotnet/ -name libcoreclr.so`)
ENTRYPOINT ["/bin/bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment