Permalink
Browse files

Run the app with faker using Traveling Ruby

  • Loading branch information...
1 parent a0ca3be commit 3a3cfe89c5a65527be141256c5ab85700d1114ae @adomokos committed May 27, 2016
Showing with 27 additions and 14 deletions.
  1. +18 −12 Makefile
  2. +3 −0 resources/bundler-config
  3. +6 −2 resources/wrapper.sh
View
@@ -5,6 +5,24 @@ THIS_FILE := $(lastword $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
+run: ## Runs the code locally
+ @echo 'Run the app locally'
+ @echo '-------------------'
+ @rm -fr $(OSXDIR)
+ @mkdir -p $(OSXDIR)/lib/ruby
+ @tar -xzf resources/traveling-ruby-20150715-2.2.2-osx.tar.gz -C $(OSXDIR)/lib/ruby
+ @mkdir $(OSXDIR)/lib/app
+ @cp hello_ruby/lib/hello.rb $(OSXDIR)/lib/app/hello.rb
+ @cp -pR hello_ruby/vendor $(OSXDIR)/lib/
+ @rm -f $(OSXDIR)/lib/vendor/*/*/cache/*
+ @mkdir -p $(OSXDIR)/lib/vendor/.bundle
+ @cp resources/bundler-config $(OSXDIR)/lib/vendor/.bundle/config
+ @cp hello_ruby/Gemfile $(OSXDIR)/lib/vendor/
+ @cp hello_ruby/Gemfile.lock $(OSXDIR)/lib/vendor/
+ @cp resources/wrapper.sh $(OSXDIR)/hello
+ @chmod +x $(OSXDIR)/hello
+ @cd $(OSXDIR) && ./hello
+
package: ## Package the code for AWS Lambda
@echo 'Package the app for deploy'
@echo '--------------------------'
@@ -22,18 +40,6 @@ package: ## Package the code for AWS Lambda
cd $(LAMBDADIR) && mv hello_ruby.zip ../deploy/
@echo '... Done.'
-run: ## Runs the code locally
- @echo 'Run the app locally'
- @echo '-------------------'
- @rm -fr $(OSXDIR)
- @mkdir -p $(OSXDIR)/lib/ruby
- @tar -xzf resources/traveling-ruby-20150715-2.2.2-osx.tar.gz -C $(OSXDIR)/lib/ruby
- @mkdir $(OSXDIR)/lib/app
- @cp hello_ruby/lib/hello.rb $(OSXDIR)/lib/app/hello.rb
- @cp resources/wrapper.sh $(OSXDIR)/hello
- @chmod +x $(OSXDIR)/hello
- @cd $(OSXDIR) && ./hello
-
create: ## Creates an AWS lambda function
aws lambda create-function \
--function-name HelloFromRuby \
@@ -0,0 +1,3 @@
+BUNDLE_PATH: .
+BUNDLE_WITHOUT: development:test
+BUNDLE_DISABLE_SHARED_GEMS: '1'
@@ -5,5 +5,9 @@ set -e
SELFDIR="`dirname \"$0\"`"
SELFDIR="`cd \"$SELFDIR\" && pwd`"
-# Run the actual app using the bundled Ruby interpreter.
-exec "$SELFDIR/lib/ruby/bin/ruby" "$SELFDIR/lib/app/hello.rb"
+# Tell Bundler where the Gemfile and gems are.
+export BUNDLE_GEMFILE="$SELFDIR/lib/vendor/Gemfile"
+unset BUNDLE_IGNORE_CONFIG
+
+# Run the actual app using the bundled Ruby interpreter, with Bundler activated.
+exec "$SELFDIR/lib/ruby/bin/ruby" -rbundler/setup "$SELFDIR/lib/app/hello.rb"

0 comments on commit 3a3cfe8

Please sign in to comment.