Skip to content

Commit

Permalink
Embed README in nuget package
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjarobot committed Mar 19, 2022
1 parent ae1a9f4 commit 8608669
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100
dotnet-version: 6.0.201
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pack-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100
dotnet-version: 6.0.201
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,34 @@ A list of instructions is passed to the `buildDockerfile` command, which will
return a string representation of that Dockerfile.

```fsharp
[
From ("debian", Some("stretch-slim"), None)
Run (Exec ("apt-get", ["update"]))
Run (Exec ("apt-get", ["install"; "-y"; "wget"]))
Env (KeyValuePair("LANG", "C.UTF-8"))
Copy (SingleSource("."), "/app", None)
WorkDir ("/app")
Cmd (ShellCommand ("wget https://github.com/fsharp/fsharp/archive/4.1.25.tar.gz"))
]
|> Dockerfile.buildDockerfile
#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.

```dockerfile
FROM debian:stretch-slim
RUN ["apt-get","update"]
FROM mcr.microsoft.com/dotnet/sdk:5.0.302 AS builder
RUN ["apt-get","install","-y","wget"]
ENV LANG C.UTF-8
COPY . /app
WORKDIR /app
CMD wget https://github.com/fsharp/fsharp/archive/4.1.25.tar.gz
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
Expand Down
2 changes: 2 additions & 0 deletions src/FSharp.Text.Docker.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Copyright>Copyright (c) 2017-2021 Dave Curylo</Copyright>
<Description>Building Dockerfiles from F#.</Description>
<PackageProjectUrl>https://github.com/ninjarobot/FSharp.Text.Docker</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>docker;fsharp</PackageTags>
<Authors>dcurylo</Authors>
</PropertyGroup>
Expand All @@ -13,6 +14,7 @@
</ItemGroup>
<ItemGroup>
<None Include="../LICENSE" Pack="true" PackagePath="" />
<None Include="../README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net6.0' ">
<PackageReference Update="FSharp.Core" Version="5.0.0" />
Expand Down

0 comments on commit 8608669

Please sign in to comment.