Dockerize F# with Paket

I recently started learning F#, the functional language for the .NET Framework.
So far, I enjoy it very much!
To gain some experience using the language, I developed RailMail.

After finishing the first features, I wanted to setup a Dockerfile - only to find out that it is not exactly trivial and there are no examples or tutorial that use Paket.

I wanted to make this tutorial so that you will have an easier time dockerizing your F# solution.

Dockerfile

There are two build stages involved:

Compile the sources

Configure the runtime

These steps will be explained, you can see an example Dockerfile at the end of the article.

1. Compile the Sources

Paket needs Mono to work, so the standard microsoft/dotnet:sdk image doesn’t work for building.
Instead, I used dcurylo/fsharp-mono-netcore, which extends that by mono.
Notice the AS-Directive: This tags this build stage for latter reuse.

FROM dcurylo/fsharp-mono-netcore AS build-envWORKDIR /app

The first step is to install a new version of Paket using the bootstrapper.