Create a gist now

Instantly share code, notes, and snippets.

@koseki /README.md
Last active Aug 29, 2015

vagrant-layout: Ruby on Rails

Vagrant Layout - Ruby on Rails

This is configuration of vagrant-layout plugin. Based on ruby layout.

Installation

$ vagrant plugin install vagrant-layout
$ mkdir my-project && cd my-project
$ vagrant layout init https://gist.github.com/koseki/37f61d9a02b9a48e6651

Double click sandbox/osx/manage/start.command or start.bat. Wait a while, and access http://localhost:8080/.

Feel free to fork and create your own layout.


base: https://github.com/koseki/vagrant-layout/commit/761e2119a467117e6bb7b8512eb0e38d90714e72

diff --git a/sandbox/Procfile b/sandbox/Procfile
index a60cbb3..74c30f4 100644
--- a/sandbox/Procfile
+++ b/sandbox/Procfile
@@ -1,2 +1,4 @@
+sample-app: sh -c "cd ../sample-app && bundle exec rails server"
nginx: ./bin/nginx.sh
error.log: tail -n 0 -f logs/error.log
+development.log: tail -n 0 -f ../sample-app/log/development.log
diff --git a/sandbox/bin/boot.sh b/sandbox/bin/boot.sh
index 4c475b2..34177e3 100644
--- a/sandbox/bin/boot.sh
+++ b/sandbox/bin/boot.sh
@@ -1,8 +1,21 @@
#! /bin/sh
set -e
-cd `dirname $0`/..
+cd `dirname $0`/../..
+# Remove these lines after creating application.
+if [ ! -d sample-app ]; then
+ rails new -d mysql sample-app
+ cd sample-app
+ bundle install
+ bundle exec rake db:create db:migrate
+ cd ..
+fi
+
+cd sample-app
+bundle install
+
+cd ../sandbox
touch logs/error.log
./bin/shoreman
diff --git a/sandbox/bin/provision.sh b/sandbox/bin/provision.sh
index 6366db4..47c83da 100755
--- a/sandbox/bin/provision.sh
+++ b/sandbox/bin/provision.sh
@@ -77,3 +77,21 @@ if [ $CURRENT_VERSION -lt $VERSION ]; then
echo $VERSION > $VERSION_FILE
fi
+
+VERSION=`expr $VERSION + 1`
+if [ $CURRENT_VERSION -lt $VERSION ]; then
+ echo "--- $VERSION: node.js ---"
+
+ yum install -y nodejs npm --enablerepo=epel
+
+ echo $VERSION > $VERSION_FILE
+fi
+
+VERSION=`expr $VERSION + 1`
+if [ $CURRENT_VERSION -lt $VERSION ]; then
+ echo "--- $VERSION: rails ---"
+
+ gem install rails -v 4.2.0
+
+ echo $VERSION > $VERSION_FILE
+fi
diff --git a/sandbox/config/nginx.conf.src b/sandbox/config/nginx.conf.src
index a933399..fb08f8e 100644
--- a/sandbox/config/nginx.conf.src
+++ b/sandbox/config/nginx.conf.src
@@ -30,9 +30,15 @@ http {
server_name project.local;
client_max_body_size 8M;
index index.html index.htm;
+ root PROJECT_ROOT/sample-app/static/public;
- location / {
- root PROJECT_ROOT/static/htdocs;
+ try_files $uri $uri/index.html @rails;
+
+ location @rails {
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_pass http://localhost:3000;
}
location /favicon.ico {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment