Added hello example.

This commit is contained in:
Travis Reeder
2016-07-19 12:29:02 -07:00
parent c5abab9f15
commit edc126eb81
11 changed files with 113 additions and 39 deletions

2
examples/hello/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
bundle/
.bundle/

View File

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

3
examples/hello/Gemfile Normal file
View File

@@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem 'json', '> 1.8.2'

View File

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

33
examples/hello/README.md Normal file
View File

@@ -0,0 +1,33 @@
This is a worker that just echoes the "input" param in the payload.
eg:
This input:
```json
{
"name": "Johnny Utah"
}
```
Will output:
```
Hello Johnny Utah!
```
## Building Image
```
# SET BELOW TO YOUR DOCKER HUB USERNAME
USERNAME=YOUR_DOCKER_HUB_USERNAME
# build it
docker build -t $USERNAME/hello .
# test it
docker run -e 'PAYLOAD={"name": "Johnny"}' $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
```

1
examples/hello/VERSION Normal file
View File

@@ -0,0 +1 @@
0.0.27

15
examples/hello/hello.rb Normal file
View File

@@ -0,0 +1,15 @@
require 'json'
name = "World"
# payload = STDIN.read
# or using env vars: ENV['PAYLOAD']
payload = ENV['PAYLOAD']
puts 'ARGF: ' + payload.inspect
if payload != ""
payload = JSON.parse(payload)
name = payload['name']
end
puts "Hello #{name}!"