diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89b03f97f..d8851556d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,31 +21,3 @@ docker run --env-file .env --rm -it --privileged -p 8080:8080 iron/functions ```sh ./release.sh ``` - -## FOR INFLUX AND ANALYTICS - - -```sh -docker run -p 8083:8083 -p 8086:8086 \ - -v $PWD:/var/lib/influxdb \ - --rm --name influxdb \ - influxdb:alpine -``` - -CLI: - -```sh -docker run --rm --link influxdb -it influxdb:alpine influx -host influxdb -``` - -chronograf: - -```sh -# they don't have an alpine image yet chronograf -docker run -p 10000:10000 --link influxdb chronograf -``` - -Open UI: http://localhost:10000 - -Add server with host `influxdb` - diff --git a/README.md b/README.md index c5639699b..3f26e586d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ iron create app APP_NAME curl -H "Content-Type: application/json" -X POST -d '{"name":"APP_NAME"}' http://localhost:8080/api/v1/apps ``` -### Create a Route +### Create a Route for your Function Now add routes to the app. First we'll add a route to the output of a docker container: @@ -33,14 +33,24 @@ iron add route myapp /hello iron/hello curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello", "image":"iron/hello"}' http://localhost:8080/api/v1/apps/myapp/routes ``` -Surf to your function: http://localhost:8080/hello?app=APP_NAME . Boom! - -And how about a [slackbot](https://github.com/treeder/slackbots/tree/master/guppy) endpoint: +And how about a [slackbot](https://github.com/treeder/slackbots/tree/master/guppy) too: ```sh curl -H "Content-Type: application/json" -X POST -d '{"path":"/guppy","image":"treeder/guppy:0.0.2", "content_type": "application/json"}' http://localhost:8080/api/v1/apps/myapp/routes ``` +### Calling your Function + +Surf to your function: http://localhost:8080/hello?app=APP_NAME . Boom! + +#### To pass in data to your function, + +Your function will get the body of the request as is, and the headers of the request will be passed in as env vars. + +```sh +curl -H "Content-Type: application/json" -X POST -d '{"name":"Johnny"}' http://localhost:8080/hello?app=APP_NAME +``` + ### Using IronFunctions Hosted by Iron.io Simply point to https://functions.iron.io instead of localhost and add your Iron.io Authentication header (TODO: link), like this: @@ -55,7 +65,29 @@ And you'll get an ironfunctions.com host: APP_NAME.ironfunctions.com/PATH ``` -## Updating Your Images +### Updating Your Images Tag your images with a version, eg `treeder/guppy:0.0.5` then use that including the tag and update the route. + +## Examples + +TODO: Link to examples in various languages +TODO: Link to slackbots (easiest way to host slackbots?) + +## Operations + +This is info on how to run and manage IronFunctions. + +### Logging + +Run logspout container on your server. + +#### Monitoring + +TODO + +### Scaling + +TODO + diff --git a/analytics/README.md b/analytics/README.md deleted file mode 100644 index a846fd644..000000000 --- a/analytics/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -Test with: - -ruby -run -e httpd . -p 9090 diff --git a/analytics/test.html b/analytics/test.html deleted file mode 100644 index 6daf03fa9..000000000 --- a/analytics/test.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/hello/.gitignore b/examples/hello/.gitignore new file mode 100644 index 000000000..e715a8a80 --- /dev/null +++ b/examples/hello/.gitignore @@ -0,0 +1,2 @@ +bundle/ +.bundle/ diff --git a/examples/hello/Dockerfile b/examples/hello/Dockerfile new file mode 100644 index 000000000..efa975b05 --- /dev/null +++ b/examples/hello/Dockerfile @@ -0,0 +1,9 @@ +FROM iron/ruby:dev + +WORKDIR /worker +ADD Gemfile* /worker/ +RUN bundle install + +ADD . /worker/ + +ENTRYPOINT ["ruby", "hello.rb"] diff --git a/examples/hello/Gemfile b/examples/hello/Gemfile new file mode 100644 index 000000000..e05a90012 --- /dev/null +++ b/examples/hello/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'json', '> 1.8.2' diff --git a/examples/hello/Gemfile.lock b/examples/hello/Gemfile.lock new file mode 100644 index 000000000..28ab22fe5 --- /dev/null +++ b/examples/hello/Gemfile.lock @@ -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 diff --git a/examples/hello/README.md b/examples/hello/README.md new file mode 100644 index 000000000..1a90fbd30 --- /dev/null +++ b/examples/hello/README.md @@ -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 +``` diff --git a/examples/hello/VERSION b/examples/hello/VERSION new file mode 100644 index 000000000..24ff85581 --- /dev/null +++ b/examples/hello/VERSION @@ -0,0 +1 @@ +0.0.27 diff --git a/examples/hello/hello.rb b/examples/hello/hello.rb new file mode 100644 index 000000000..71ec89bba --- /dev/null +++ b/examples/hello/hello.rb @@ -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}!"