Examples changes (#201)

This commit is contained in:
Pedro Nasser
2016-11-01 18:15:27 -02:00
committed by C Cirello
parent 570fdea062
commit 5d9269e186
91 changed files with 967 additions and 424 deletions

View File

@@ -1,9 +1,9 @@
FROM iron/ruby:dev
WORKDIR /worker
ADD Gemfile* /worker/
WORKDIR /function
ADD Gemfile* /function/
RUN bundle install
ADD . /worker/
ADD . /function/
ENTRYPOINT ["ruby", "hello.rb"]
ENTRYPOINT ["ruby", "function.rb"]

View File

@@ -1,13 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
json (1.8.3)
PLATFORMS
ruby
DEPENDENCIES
json (> 1.8.2)
BUNDLED WITH
1.10.5

View File

@@ -1,23 +1,77 @@
This is a worker that just echoes the "input" param in the payload.
# Hello Function Image (Ruby)
eg:
This images compares the payload info with the header.
This input:
## Requirements
```json
{
"name": "Johnny Utah"
}
```
- IronFunctions API
Will output:
## Development
### Building image locally
```
Hello Johnny Utah!
# SET BELOW TO YOUR DOCKER HUB USERNAME
USERNAME=YOUR_DOCKER_HUB_USERNAME
# build it
./build.sh
```
## Try it
### Publishing to DockerHub
```
echo '{"name":"Johnny"}' | docker run --rm -i iron/hello
# tagging
docker run --rm -v "$PWD":/app treeder/bump patch
docker tag $USERNAME/func-hello-ruby:latest $USERNAME/func-hello-ruby:`cat VERSION`
# pushing to docker hub
docker push $USERNAME/func-hello-ruby
```
### Testing image
```
./test.sh
```
## Running it on IronFunctions
### Let's define some environment variables
```
# Set your Function server address
# Eg. 127.0.0.1:8080
FUNCAPI=YOUR_FUNCTIONS_ADDRESS
```
### Running with IronFunctions
With this command we are going to create an application with name `hello`.
```
curl -X POST --data '{
"app": {
"name": "hello",
}
}' http://$FUNCAPI/v1/apps
```
Now, we can create our route
```
curl -X POST --data '{
"route": {
"image": "'$USERNAME'/func-hello-ruby",
"path": "/hello",
}
}' http://$FUNCAPI/v1/apps/hello/routes
```
#### Testing function
Now that we created our IronFunction route, let's test our new route
```
curl -X POST --data '{"name": "Johnny"}' http://$FUNCAPI/r/hello/hello
```

View File

@@ -1 +1 @@
0.0.30
0.0.1

4
examples/hello-ruby/build.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
set -ex
docker build -t iron/func-hello-ruby .

View File

@@ -0,0 +1,3 @@
image: iron/func-hello-ruby
build:
- ./build.sh

View File

@@ -1,9 +0,0 @@
USERNAME=iron
# build it
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
# push it
docker push $USERNAME/hello:ruby

9
examples/hello-ruby/test.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -x
./build.sh
PAYLOAD='{"name":"Johnny"}'
# test it
echo $PAYLOAD | docker run --rm -i -e TEST=1 iron/func-hello-ruby