From 6319b18b1bfd211874d7680c1fc416ddb7a97928 Mon Sep 17 00:00:00 2001 From: kunihikot Date: Tue, 3 Oct 2017 14:37:42 +0900 Subject: [PATCH] Updated the document of examples/error --- examples/error/Dockerfile | 9 --- examples/error/README.md | 75 ++++++------------------- examples/error/VERSION | 1 - examples/error/build.sh | 4 -- examples/error/{function.rb => func.rb} | 1 + 5 files changed, 19 insertions(+), 71 deletions(-) delete mode 100644 examples/error/Dockerfile delete mode 100644 examples/error/VERSION delete mode 100755 examples/error/build.sh rename examples/error/{function.rb => func.rb} (84%) diff --git a/examples/error/Dockerfile b/examples/error/Dockerfile deleted file mode 100644 index f810193e..00000000 --- a/examples/error/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM iron/ruby:dev - -WORKDIR /worker -ADD Gemfile* /worker/ -RUN bundle install - -ADD . /worker/ - -ENTRYPOINT ["ruby", "error.rb"] diff --git a/examples/error/README.md b/examples/error/README.md index 3e210a9c..7615f31d 100644 --- a/examples/error/README.md +++ b/examples/error/README.md @@ -2,37 +2,18 @@ This images compares the payload info with the header. -## Requirements - -- IronFunctions API - -## Development - -### Building image locally - -``` -# SET BELOW TO YOUR DOCKER HUB USERNAME -USERNAME=YOUR_DOCKER_HUB_USERNAME - -# build it -./build.sh -``` - -### Publishing to DockerHub - -``` -# tagging -docker run --rm -v "$PWD":/app treeder/bump patch -docker tag $USERNAME/func-error:latest $USERNAME/func-error:`cat VERSION` - -# pushing to docker hub -docker push $USERNAME/func-error -``` - -### Testing image - ``` -./test.sh +# Create your func.yaml file +fn init /func-error +# Build the function +fn build +# Test it +echo '{"input": "yoooo"}' | fn run +# Push it to Docker Hub +fn push +# Create routes to this function on IronFunctions +fn apps create +fn routes create /error ``` ## Running it on IronFunctions @@ -41,37 +22,17 @@ docker push $USERNAME/func-error ``` # Set your Function server address -# Eg. 127.0.0.1:8080 +# Eg. +# FUNCAPI=127.0.0.1:8080 +# APPNAME=error FUNCAPI=YOUR_FUNCTIONS_ADDRESS +APPNAME=YOUR_APP ``` -### Running with IronFunctions - -With this command we are going to create an application with name `error`. - -``` -curl -X POST --data '{ - "app": { - "name": "error", - } -}' http://$FUNCAPI/v1/apps -``` - -Now, we can create our route - -``` -curl -X POST --data '{ - "route": { - "image": "'$USERNAME'/func-error", - "path": "/error", - } -}' http://$FUNCAPI/v1/apps/error/routes -``` - -#### Testing function +### Testing function Now that we created our IronFunction route, let's test our new route ``` -curl -X POST --data '{"input": "yoooo"}' http://$FUNCAPI/r/error/error -``` \ No newline at end of file +curl -X POST --data '{"input": "yoooo"}' http://$FUNCAPI/r/$APPNAME/error +``` diff --git a/examples/error/VERSION b/examples/error/VERSION deleted file mode 100644 index 8a9ecc2e..00000000 --- a/examples/error/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.1 \ No newline at end of file diff --git a/examples/error/build.sh b/examples/error/build.sh deleted file mode 100755 index c93fa16b..00000000 --- a/examples/error/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -ex - -docker build -t iron/func-error . \ No newline at end of file diff --git a/examples/error/function.rb b/examples/error/func.rb similarity index 84% rename from examples/error/function.rb rename to examples/error/func.rb index a86263bd..38404539 100644 --- a/examples/error/function.rb +++ b/examples/error/func.rb @@ -1,3 +1,4 @@ +require_relative 'bundle/bundler/setup' require 'json' payload = STDIN.read