Go build helper script (#163)

Create a docker container and a script to call it, to help people build go plugins for use with fission.
This commit is contained in:
Soam Vasani
2017-03-27 23:26:59 -07:00
committed by GitHub
parent a13015e75a
commit a6eb4c6d31
5 changed files with 30 additions and 15 deletions
+6 -1
View File
@@ -2,7 +2,7 @@
This is the Go environment for Fission. This is the Go environment for Fission.
It's a Docker image containing a Go 1.8rc3 runtime, along with a dynamic loader. It's a Docker image containing a Go 1.8 runtime, along with a dynamic loader.
## Build this image ## Build this image
@@ -27,3 +27,8 @@ fission env update --name go-runtime --image USER/go-runtime
After this, fission functions that have the env parameter set to the After this, fission functions that have the env parameter set to the
same environment name as this command will use this environment. same environment name as this command will use this environment.
## Creating functions to use this image
See the [examples README](examples/go/README.md).
+5
View File
@@ -0,0 +1,5 @@
FROM golang:1.8
ENV GOPATH /usr
RUN go get github.com/fission/fission
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
if [ $# -eq 0 ]
then
echo "No arguments, building current dir"
filename='.'
else
filename=$1
fi
docker run --rm -v $(pwd):/build -w /build fission/go-builder go build -buildmode=plugin -o function.so $filename && echo "Compiled plugin: function.so. Use 'fission function create' to upload to fission."
+8 -6
View File
@@ -4,8 +4,11 @@ The `go` runtime uses the [`plugin` package](https://golang.org/pkg/plugin/) to
## Requirements ## Requirements
- go 1.8 To use this environment, download the [build helper
- A [go-runtime fission environment](environments/go/README.md) script](environments/go/builder/go-function-build).
The script must be run in the same directory as the function you're
building.
## Examples ## Examples
@@ -13,13 +16,12 @@ The `go` runtime uses the [`plugin` package](https://golang.org/pkg/plugin/) to
`hello.go` is an very basic HTTP handler returning `"Hello, World!"`. `hello.go` is an very basic HTTP handler returning `"Hello, World!"`.
``` ```
# Build the function as a plugin # Build the function as a plugin. Outputs result to 'function.so'.
$ ./build.sh $ go-function-build hello.go
# Upload the function to fission # Upload the function to fission
$ fission function create --name hello --env go-runtime --package hello.so $ fission function create --name hello --env go-runtime --package function.so
# Map /hello to the hello function # Map /hello to the hello function
$ fission route create --method GET --url /hello --function hello $ fission route create --method GET --url /hello --function hello
-8
View File
@@ -1,8 +0,0 @@
#!/bin/sh
FISSION_PATH="github.com/fission/fission"
docker run --rm -v $GOPATH/src/$FISSION_PATH:/usr/src/$FISSION_PATH \
-e GOPATH=/usr/ \
-w /usr/src/$FISSION_PATH/examples/go \
golang:1.8 go build -buildmode=plugin -o hello.so hello.go