mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: support for dotnet (#326)
* Add initial support for dotnet * Initial work on dotnet example * fn: fix docker incantation * fn: .gitignore * Add README.md for dotnet example * Update docs
This commit is contained in:
committed by
C Cirello
parent
52d0dc941c
commit
717d8455e9
@@ -15,6 +15,8 @@ func GetLangHelper(lang string) (LangHelper, error) {
|
||||
return &PythonHelper{}, nil
|
||||
case "rust":
|
||||
return &RustLangHelper{}, nil
|
||||
case "dotnet":
|
||||
return &DotNetLangHelper{}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("No language helper found for %v", lang)
|
||||
}
|
||||
|
||||
42
fn/langs/dotnet.go
Normal file
42
fn/langs/dotnet.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package langs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type DotNetLangHelper struct{}
|
||||
|
||||
func (lh *DotNetLangHelper) Entrypoint() string {
|
||||
return "dotnet dotnet.dll"
|
||||
}
|
||||
|
||||
func (lh *DotNetLangHelper) HasPreBuild() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// PreBuild for Go builds the binary so the final image can be as small as possible
|
||||
func (lh *DotNetLangHelper) PreBuild() error {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := exec.Command(
|
||||
"docker", "run",
|
||||
"--rm", "-v",
|
||||
wd+":/dotnet", "-w", "/dotnet", "microsoft/dotnet",
|
||||
"/bin/sh", "-c", "dotnet restore && dotnet publish -c release -b /tmp -o .",
|
||||
)
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("error running docker build: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (lh *DotNetLangHelper) AfterBuild() error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user