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

Method PreBuild

fn/langs/python.go:23–41  ·  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

21
22// PreBuild for Go builds the binary so the final image can be as small as possible
23func (lh *PythonHelper) PreBuild() error {
24 wd, err := os.Getwd()
25 if err != nil {
26 return err
27 }
28
29 pbcmd := fmt.Sprintf("docker run --rm -v %s:/worker -w /worker iron/python:2-dev pip install -t packages -r requirements.txt", wd)
30 fmt.Println("Running prebuild command:", pbcmd)
31 parts := strings.Fields(pbcmd)
32 head := parts[0]
33 parts = parts[1:len(parts)]
34 cmd := exec.Command(head, parts...)
35 cmd.Stderr = os.Stderr
36 cmd.Stdout = os.Stdout
37 if err := cmd.Run(); err != nil {
38 return fmt.Errorf("error running docker build: %v", err)
39 }
40 return nil
41}
42
43func (lh *PythonHelper) AfterBuild() error {
44 return nil

Callers

nothing calls this directly

Calls 2

CommandMethod · 0.80
RunMethod · 0.80

Tested by

no test coverage detected