Skip to content

Instantly share code, notes, and snippets.

@alexellis
Last active September 24, 2017 11:54
Show Gist options
  • Save alexellis/cd50a1d957702164e1a830ed42d993d4 to your computer and use it in GitHub Desktop.
Save alexellis/cd50a1d957702164e1a830ed42d993d4 to your computer and use it in GitHub Desktop.
YouTube GIF maker

Serverless YouTube GIF maker

Live Preview - Jedi Kittens: https://twitter.com/alexellisuk/status/911290757314744322

Instructions:

Get OpenFaaS with instructions @ https://github.com/alexellis/faas/blob/master/guide/deployment_swarm.md

Edit docker-compose.yml:

$ git diff docker-compose.yml 
diff --git a/docker-compose.yml b/docker-compose.yml
index 9d91cff..cfcde24 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -10,6 +10,8 @@ services:
             - functions
         environment:
             dnsrr: "true"  # Temporarily use dnsrr in place of VIP while issue persists on PWD
+            read_timeout: 65    # seconds
+            write_timeout: 65   # seconds
         deploy:
             placement:
                 constraints:

Then re-deploy:

./deploy_stack.sh

And deploy the functions:

$ faas-cli -action deploy   --env write_debug=false -image alexellis2/faas-youtubedl:0.2   -name youtubedl   -fprocess="sh ./entry.sh" --env read_timeout=60 --env write_timeout=60

$ faas-cli deploy --env write_debug=false --env read_timeout=60 --env write_timeout=60 --fprocess="./entry.sh"   --image alexellis/gif-maker --name gif-maker

Now try it out:

$ curl localhost:8080/function/youtubedl \
-d "https://www.youtube.com/watch?v=NtgtMQwr3Ko"  \
| curl -X POST localhost:8080/function/gif-maker --data-binary @- > yt.gif

Your gif will be in the "yt.gif" file. Enjoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment