-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ var ( | |
".go": "go", | ||
".js": "node", | ||
".rb": "ruby", | ||
".py": "python", | ||
} | ||
|
||
fnInitRuntimes []string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package langs | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
type PythonHelper struct { | ||
} | ||
|
||
func (lh *PythonHelper) Entrypoint() string { | ||
return "python2 func.py" | ||
} | ||
|
||
func (lh *PythonHelper) HasPreBuild() bool { | ||
return true | ||
} | ||
|
||
// PreBuild for Go builds the binary so the final image can be as small as possible | ||
func (lh *PythonHelper) PreBuild() error { | ||
wd, err := os.Getwd() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pbcmd := fmt.Sprintf("docker run --rm -v %s:/worker -w /worker iron/python:2-dev pip install -t packages -r requirements.txt", wd) | ||
fmt.Println("Running prebuild command:", pbcmd) | ||
parts := strings.Fields(pbcmd) | ||
head := parts[0] | ||
parts = parts[1:len(parts)] | ||
cmd := exec.Command(head, parts...) | ||
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 *PythonHelper) AfterBuild() error { | ||
return nil | ||
} |