FSharp.Text.Docker
1.0.16
dotnet add package FSharp.Text.Docker --version 1.0.16
NuGet\Install-Package FSharp.Text.Docker -Version 1.0.16
<PackageReference Include="FSharp.Text.Docker" Version="1.0.16" />
paket add FSharp.Text.Docker --version 1.0.16
#r "nuget: FSharp.Text.Docker, 1.0.16"
// Install FSharp.Text.Docker as a Cake Addin #addin nuget:?package=FSharp.Text.Docker&version=1.0.16 // Install FSharp.Text.Docker as a Cake Tool #tool nuget:?package=FSharp.Text.Docker&version=1.0.16
FSharp.Text.Docker
Interact with docker with the type safety of the F# language.
Define a dockerfile
A dockerfile can be built using a set of types for all of the supported instructions, providing type safety and compile time checking when building a Dockerfile.
A list of instructions is passed to the buildDockerfile
command, which will
return a string representation of that Dockerfile.
#r "nuget: FSharp.Text.Docker"
open FSharp.Text.Docker.Builders
let dockerSpecBuilder = dockerfile {
from_stage "mcr.microsoft.com/dotnet/sdk:5.0.302" "builder"
run_exec "apt-get" "install -y wget"
run "dotnet new console -lang F# -n foo"
workdir "foo"
run "dotnet build -c Release -o app"
from "mcr.microsoft.com/dotnet/runtime:5.0.8"
expose 80
copy_from "builder" "/path/to/source/myApp.dll" "/path/to/dest"
cmd "dotnet /path/to/dest/myApp.dll"
}
dockerSpecBuilder.Build() |> System.Console.WriteLine
The output can be saved as a Dockerfile like the one below.
FROM mcr.microsoft.com/dotnet/sdk:5.0.302 AS builder
RUN ["apt-get","install","-y","wget"]
RUN dotnet new console -lang F# -n foo
WORKDIR foo
RUN dotnet build -c Release -o app
FROM mcr.microsoft.com/dotnet/runtime:5.0.8
EXPOSE 80
COPY --from=builder /path/to/source
With the full F# language, it becomes relatively simple to use complex logic in building the Dockerfile. For example, this snippet will concatenate a set of shell commands into a single RUN instruction to reduce image layers.
let multipleShellCommands =
[
"apt-get update"
"apt-get install -y --no-install-recommends wget"
"wget https://github.com/fsprojects/Paket/releases/download/5.95.0/paket.exe"
"chmod a+r paket.exe && mv paket.exe /usr/local/lib/"
"""printf '#!/bin/sh\nexec /usr/bin/mono /usr/local/lib/paket.exe "$@"' >> /usr/local/bin/paket"""
"chmod u+x /usr/local/bin/paket"
]
|> String.concat " \ \n && "
[
From ("fsharp", Some("4.1.25"), None)
Run (ShellCommand (multipleShellCommands))
Entrypoint (Exec ("paket", []))
] |> Dockerfile.buildDockerfile
|> printfn "%s"
The resulting output is a dockerfile as follows, useful for a small image to execute paket:
FROM fsharp:4.1.25
RUN apt-get update \
&& apt-get install -y --no-install-recommends wget \
&& wget https://github.com/fsprojects/Paket/releases/download/5.95.0/paket.exe \
&& chmod a+r paket.exe && mv paket.exe /usr/local/lib/ \
&& printf '#!/bin/sh\nexec /usr/bin/mono /usr/local/lib/paket.exe "$@"' >> /usr/local/bin/paket \
&& chmod u+x /usr/local/bin/paket
ENTRYPOINT ["paket"]
More to come
- Build images (not yet)
- Run containers (not yet)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- FSharp.Core (>= 5.0.0)
- System.Text.Json (>= 5.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.16 | 1,733 | 12/2/2022 |
1.0.15 | 325 | 12/2/2022 |
1.0.14 | 333 | 12/2/2022 |
1.0.13 | 312 | 12/1/2022 |
1.0.12 | 324 | 12/1/2022 |
1.0.11 | 321 | 12/1/2022 |
1.0.10 | 332 | 12/1/2022 |
1.0.9 | 322 | 12/1/2022 |
1.0.8 | 954 | 3/19/2022 |
1.0.7 | 534 | 11/15/2021 |
1.0.6 | 357 | 8/2/2021 |
1.0.5 | 370 | 7/29/2021 |
1.0.4 | 337 | 7/28/2021 |
1.0.3 | 979 | 3/28/2018 |
1.0.2 | 935 | 3/28/2018 |
1.0.1 | 906 | 3/28/2018 |
1.0.0 | 1,012 | 3/28/2018 |