mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Added hello example.
This commit is contained in:
2
examples/hello/.gitignore
vendored
Normal file
2
examples/hello/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
bundle/
|
||||
.bundle/
|
||||
9
examples/hello/Dockerfile
Normal file
9
examples/hello/Dockerfile
Normal 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
3
examples/hello/Gemfile
Normal file
@@ -0,0 +1,3 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'json', '> 1.8.2'
|
||||
13
examples/hello/Gemfile.lock
Normal file
13
examples/hello/Gemfile.lock
Normal 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
33
examples/hello/README.md
Normal 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
1
examples/hello/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
0.0.27
|
||||
15
examples/hello/hello.rb
Normal file
15
examples/hello/hello.rb
Normal 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}!"
|
||||
Reference in New Issue
Block a user