mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add support for F# and set dotnet docket image to 1.0.1-projectjson (#409)
This commit is contained in:
committed by
C Cirello
parent
ad4d7ce8b9
commit
f815ab54c2
3
examples/hash/.gitignore
vendored
3
examples/hash/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
dotnet.*
|
||||
func.yaml
|
||||
project.lock.json
|
||||
@@ -18,6 +18,12 @@ fn init <username>/<funcname>
|
||||
|
||||
This will create the ```func.yaml``` file required by functions, which can be built by running:
|
||||
|
||||
|
||||
## Build the function docker image
|
||||
```bash
|
||||
fn build
|
||||
```
|
||||
|
||||
## Push to docker
|
||||
```bash
|
||||
fn push
|
||||
|
||||
39
examples/hash/fsharp/func.fs
Executable file
39
examples/hash/fsharp/func.fs
Executable file
@@ -0,0 +1,39 @@
|
||||
open System
|
||||
open System.IO
|
||||
open System.Security.Cryptography
|
||||
|
||||
let createChecksum (data:byte array) =
|
||||
use md5 = MD5.Create ()
|
||||
let hash = data |> md5.ComputeHash
|
||||
BitConverter.ToString(hash).Replace("-", "").ToLower ()
|
||||
|
||||
let downloadRemoteImageFile uri =
|
||||
async {
|
||||
let req = System.Net.HttpWebRequest.Create (System.Uri (uri)) :?> System.Net.HttpWebRequest
|
||||
let! res = req.AsyncGetResponse ()
|
||||
let stm = res.GetResponseStream ()
|
||||
use ms = new MemoryStream ()
|
||||
stm.CopyTo(ms)
|
||||
return ms.ToArray ()
|
||||
}
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
let isPipedInput =
|
||||
try
|
||||
Console.KeyAvailable |> ignore
|
||||
false
|
||||
with
|
||||
| _ -> true
|
||||
|
||||
match isPipedInput with
|
||||
| true ->
|
||||
let input = stdin
|
||||
async {
|
||||
let! uri = input.ReadToEndAsync () |> Async.AwaitTask
|
||||
return! downloadRemoteImageFile uri
|
||||
} |> Async.RunSynchronously
|
||||
|> createChecksum
|
||||
|> printfn "%s"
|
||||
| false -> () // if nothing is being piped in, then exit
|
||||
0
|
||||
27
examples/hash/fsharp/project.json
Normal file
27
examples/hash/fsharp/project.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true,
|
||||
"compilerName": "fsc",
|
||||
"compile": {
|
||||
"includeFiles": [
|
||||
"func.fs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tools": {
|
||||
"dotnet-compile-fsc": "1.0.0-preview2.1-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.1": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.1.0"
|
||||
},
|
||||
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ var (
|
||||
".py": "python",
|
||||
".rs": "rust",
|
||||
".cs": "dotnet",
|
||||
".fs": "dotnet",
|
||||
}
|
||||
|
||||
fnInitRuntimes []string
|
||||
|
||||
@@ -26,7 +26,7 @@ func (lh *DotNetLangHelper) PreBuild() error {
|
||||
cmd := exec.Command(
|
||||
"docker", "run",
|
||||
"--rm", "-v",
|
||||
wd+":/dotnet", "-w", "/dotnet", "microsoft/dotnet",
|
||||
wd+":/dotnet", "-w", "/dotnet", "microsoft/dotnet:1.0.1-sdk-projectjson",
|
||||
"/bin/sh", "-c", "dotnet restore && dotnet publish -c release -b /tmp -o .",
|
||||
)
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
Reference in New Issue
Block a user