Simple F# DSL for generating dockerfiles.
- To work with more flexing scripts and ability to reuse Dockerfile code.
- Becouse I can.
#r "nuget: Tuffenuff"
open System.IO
open Tuffenuff
df [
!/ "Simple Hello World dockerfile"
from "alpine:3.18"
cmd [| "echo" ; "'Hello world'" |]
]
|> render
|> toFile (Path.Combine(__SOURCE_DIRECTORY__, "Dockerfile"))
will create Dockerfile
with following content:
# Simple Hello World dockerfile
FROM alpine:3.18
CMD [ "echo", "'Hello world'" ]
#r "nuget: Tuffenuff"
open Tuffenuff
open Tuffenuff.DSL
let echoMaessage () =
df [
!/ "this is from 'foo.fsx'"
!> """echo 'echo "Shalom!"' > /etc/profile.d/welcome.sh"""
]
# this is from 'Dockerfile.part'
ENTRYPOINT [ "/bin/bash", "-l" ]
#r "nuget: Tuffenuff"
#load "foo.fsx"
open System.IO
open Tuffenuff
open Tuffenuff.DSL
open foo
let part1 = echoMaessage ()
let part2 =
Dockerfile.fromFile (Path.Combine (__SOURCE_DIRECTORY__, "Dockerfile.part"))
df [
!/ "Partial dockerfile"
from "ubuntu:latest"
!&part1
!&part2
]
|> Dockerfile.render
|> Dockerfile.toFile (Path.Combine (__SOURCE_DIRECTORY__, "Dockerfile.Partial"))
will create Dockerfile
with following content:
# Partial dockerfile
FROM ubuntu:latest
# this is from 'foo.fsx'
RUN \
echo 'echo "Shalom!"' > /etc/profile.d/welcome.sh
# this is from 'Dockerfile.part'
ENTRYPOINT [ "/bin/bash", "-l" ]
See examples.
- Install DotNet SDK version 6.0.x
- Run
dotnet tool restore
- Run project tasks
dotnet fake run build.fsx -t <Target>
, where<Target>
is:CodestyleCheck
CodestyleFormat
Clean
Build
RunTests
See build.fsx
source code for more info.