Add support for F# and set dotnet docket image to 1.0.1-projectjson (#409)

This commit is contained in:
Seif Lotfy سيف لطفي
2016-12-08 19:32:36 +01:00
committed by C Cirello
parent ad4d7ce8b9
commit f815ab54c2
8 changed files with 74 additions and 4 deletions

View File

@@ -1,3 +0,0 @@
dotnet.*
func.yaml
project.lock.json

View File

@@ -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
View 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

View 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"
}
}
}
}