TLDR; The setup is available via GitHub and the you can directly pull the sunside/dotnet Docker image.
Three components are used in this process:
- An Ubuntu Trusty base image that has libuv installed (required for Kestrel)
- A mono installation that supports .NET 4.6.1
- .NET Core 1.0.1
Ubuntu Trusty’s libuv is pretty old, so we’re building it from source. The base image is pretty straightforward, just use ubuntu:trusty
, install the requirements for building libuv
, as well as a bit of candy and then immediately throw away half of the stuff:
FROM ubuntu:trusty RUN LIBUV_VERSION=1.9.1 \ && apt-get update \ && apt-get -y install vim-tiny nano curl wget autoconf automake build-essential libtool \ && curl -sSL https://github.com/libuv/libuv/archive/v${LIBUV_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \ && cd /usr/local/src/libuv-$LIBUV_VERSION \ && sh autogen.sh && ./configure && make && make install \ && rm -rf /usr/local/src/libuv-$LIBUV_VERSION \ && ldconfig \ && apt-get -y purge autoconf automake build-essential libtool \ && apt-get -y autoremove \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/*
Next step is mono. I’m using nightly builds here, but any modern installation would probably work. It’s pretty straightforward: mono-devel
is required to get the system libraries (otherwise dotnet restore
will be unable to restore frameworkDependencies
), the rest is the compiler.
ENV MONO_VERSION 4.7.0.559 ENV DEBIAN_MONO_VERSION 4.7.0.559-0nightly1 RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \ && echo "deb http://download.mono-project.com/repo/debian nightly main" > /etc/apt/sources.list.d/mono-nightly.list \ && apt-get update \ && apt-get upgrade -y \ && apt-get install -y mono-runtime=$DEBIAN_MONO_VERSION mono-mcs=$DEBIAN_MONO_VERSION mono-xbuild=$DEBIAN_MONO_VERSION mono-devel=$DEBIAN_MONO_VERSION ca-certificates-mono \ && apt-get -y autoremove \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/*
Finally, .NET Core 1.0.1 and the preview tooling (dotnet-dev-1.0.0-preview2-003131
). This block brings in the tooling:
RUN apt-get update \ && apt-get install -y apt-transport-https \ && echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list \ && apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 \ && apt-get update \ && apt-get install -y dotnet-dev-1.0.0-preview2-003131 \ && apt-get -y autoremove \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/*
For docker versions earlier than 1.11.0, you’d also need an additional environment setting to prevent this bug:
ENV LTTNG_UST_REGISTER_TIMEOUT 0
In order to prevent the “one-time” warmup of the dotnet
CLI tool, add
ENV NUGET_XMLDOC_MODE skip RUN mkdir warmup \ && cd warmup \ && dotnet new \ && cd .. \ && rm -rf warmup
The final and missing clue is this comment on GitHub: When building net4xx
(i.e. .NET Framework targets as opposed to .NET Core), you will run into pretty nasty errors stating that System.Native.dll
couldn’t be found. Simply patch in a symlink to the file already installed by .NET Core and you’ll be fine:
RUN ln -s /usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.1/System.Native.so /usr/lib/libSystem.Native.so && \ ldconfig
With that, you’re done. Grab the code here or pull the image from the Docker Hub using
docker pull sunside/dotnet:1.0.0-preview2-003131