mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Added hello-go example to make example image faster.
This commit is contained in:
1
examples/hello-go/.gitignore
vendored
Normal file
1
examples/hello-go/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/hello
|
||||
6
examples/hello-go/Dockerfile
Normal file
6
examples/hello-go/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM iron/go
|
||||
|
||||
WORKDIR /function
|
||||
ADD hello .
|
||||
|
||||
ENTRYPOINT ["./hello"]
|
||||
4
examples/hello-go/README.md
Normal file
4
examples/hello-go/README.md
Normal 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 .
|
||||
1
examples/hello-go/VERSION
Normal file
1
examples/hello-go/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
0.0.1
|
||||
8
examples/hello-go/build.sh
Executable file
8
examples/hello-go/build.sh
Executable 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 .
|
||||
26
examples/hello-go/hello.go
Normal file
26
examples/hello-go/hello.go
Normal 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
17
examples/hello-go/release.sh
Executable 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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user