MCPcopy
hub / github.com/iron-io/functions / PreBuild

Method PreBuild

fn/langs/dotnet.go:22–40  ·  view source on GitHub ↗

PreBuild for Go builds the binary so the final image can be as small as possible

()

Source from the content-addressed store, hash-verified

20
21// PreBuild for Go builds the binary so the final image can be as small as possible
22func (lh *DotNetLangHelper) PreBuild() error {
23 wd, err := os.Getwd()
24 if err != nil {
25 return err
26 }
27
28 cmd := exec.Command(
29 "docker", "run",
30 "--rm", "-v",
31 wd+":/dotnet", "-w", "/dotnet", "microsoft/dotnet:1.0.1-sdk-projectjson",
32 "/bin/sh", "-c", "dotnet restore && dotnet publish -c release -b /tmp -o .",
33 )
34 cmd.Stderr = os.Stderr
35 cmd.Stdout = os.Stdout
36 if err := cmd.Run(); err != nil {
37 return fmt.Errorf("error running docker build: %v", err)
38 }
39 return nil
40}
41
42func (lh *DotNetLangHelper) AfterBuild() error {
43 return nil

Callers

nothing calls this directly

Calls 2

CommandMethod · 0.80
RunMethod · 0.80

Tested by

no test coverage detected