Added hello-go example to make example image faster.

This commit is contained in:
Travis Reeder
2016-10-12 00:08:22 -07:00
parent df3d5b48ce
commit e85c7560c3
17 changed files with 80 additions and 11 deletions

1
examples/hello-go/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/hello

View File

@@ -0,0 +1,6 @@
FROM iron/go
WORKDIR /function
ADD hello .
ENTRYPOINT ["./hello"]

View File

@@ -0,0 +1,4 @@
set -ex
docker run --rm -v "$PWD":/go/src/github.com/treeder/hello -w /go/src/github.com/treeder/hello iron/go:dev go build -o hello
docker build -t iron/hello .

View File

@@ -0,0 +1 @@
0.0.1

8
examples/hello-go/build.sh Executable file
View File

@@ -0,0 +1,8 @@
set -ex
USERNAME=iron
IMAGE=hello
# build it
docker run --rm -v "$PWD":/go/src/github.com/iron/hello -w /go/src/github.com/iron/hello iron/go:dev go build -o hello
docker build -t $USERNAME/$IMAGE .

View File

@@ -0,0 +1,26 @@
package main
import (
"encoding/json"
"fmt"
"log"
"os"
)
type Input struct {
Name string `json:"name"`
}
func main() {
for _, e := range os.Environ() {
fmt.Println(e)
}
input := &Input{}
if err := json.NewDecoder(os.Stdin).Decode(input); err != nil {
log.Fatalln("Error! Bad input. ", err)
}
if input.Name == "" {
input.Name = "World"
}
fmt.Printf("Hello %v!\n", input.Name)
}

17
examples/hello-go/release.sh Executable file
View File

@@ -0,0 +1,17 @@
set -ex
USERNAME=iron
IMAGE=hello
# build it
./build.sh
# test it
echo '{"name":"Johnny"}' | docker run --rm -i $USERNAME/hello
# tag it
docker run --rm -v "$PWD":/app treeder/bump patch
version=`cat VERSION`
echo "version: $version"
docker tag $USERNAME/$IMAGE:latest $USERNAME/$IMAGE:$version
# push it
docker push $USERNAME/$IMAGE:latest
docker push $USERNAME/$IMAGE:$version

View File

@@ -1,10 +1,9 @@
USERNAME=iron
# build it
docker build -t $USERNAME/hello .
docker build -t $USERNAME/hello:ruby .
# test it
echo '{"name":"Johnny"}' | docker run --rm -i $USERNAME/hello
# tag it
docker run --rm -v "$PWD":/app treeder/bump patch
docker tag $USERNAME/hello:latest $USERNAME/hello:`cat VERSION`
# push it
docker push $USERNAME/hello
docker push $USERNAME/hello:ruby