From 97fd7ff6b9579fac61e34c49e76202727c6251ec Mon Sep 17 00:00:00 2001 From: JP Schneider Date: Thu, 5 Jun 2014 15:41:29 -0500 Subject: [PATCH] Add a Vagrantfile, README for it, and a note in the main readme. Also, a sample env which will work --- README-vagrant.md | 123 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 8 ++- Vagrantfile | 38 ++++++++++++++ sample.env | 9 ++++ 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 README-vagrant.md create mode 100644 Vagrantfile create mode 100644 sample.env diff --git a/README-vagrant.md b/README-vagrant.md new file mode 100644 index 0000000..60f30b8 --- /dev/null +++ b/README-vagrant.md @@ -0,0 +1,123 @@ +# Badgekit Suite Easy-Deploy Dev En + +``` + +# Included: + +* Ubuntu 12.04 Precise, 64-bit OS +* Mysql 5.5 Server, Client +* Node.js 0.10.28 +* Other various utilities/non-vanilla software includes screen, git, python, g++, wget, g++, wget, make, openjdk-7-jre-headless ruby rubygems + +**NOTE** +*This is intended to also be the Badgekit front end server, alongside this, the API for Badgekit. For the .env file and any other badgekit, see https://github.com/mozilla/openbadges-badgekit and that README* + +``` + +# Prerequisites + +* A 64-bit operating system (Macbook Air is great, Windows untested) +* vagrant ([Link](http://www.vagrantup.com/)) +* The Vagrantfile in this directory copied to your workstation where you want to run the vagrant instance for BadgekitSuite from + +``` + +# How to Use This Vagrant Easy Deploy Setup + +* First, while in Terminal in the directory in the same dir as the Vagrantfile. + + * mkdir vagrant + +* Start Vagrant (Note, this may take some time, if you have not already downloaded the base box file) + + * vagrant up + +* After that finishes,run the following commands on your local workstation + + * cd ./vagrant + + * git clone https://github.com/mozilla/openbadges-badgekit.git + + * git clone https://github.com/mozilla/badgekit-api.git +* Make a .env file in each of those dirs for the env variables, copied from the sample.env files in each the badgekit-api and openbadges-badgekit repos + + * cp ./badgekit.env ./openbadges-badgekit/.env + + * cp ./badgekitapi.env ./badgekit-api/.env + +* Now, vagrant ssh into your running instance + + * vagrant ssh + +* Login as root (avoids complications) + + * sudo -sH + +* Then, npm install it all + + * cd /vagrant/badgekit && npm install + + * cd /vagrant/openbadges-badgekit && npm install + +# **STARTING THE APPS** + +* If you aren't already root, login as root (avoids complications) + + * sudo -sH + +* I recommend using screen. http://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/ + +* Then, use the screen command by itself to open a new screen + + * cd /vagrant/badgekit + + * foreman start web + +* To exit the badgekit screen, hit the following keyboard keys (including CAPS as noted) + + * Ctrl-A, Ctrl-D + +* You will be back in your original "session" on the vagrant box + +* You can now repeat the same process using the following commands + + * screen + +* **ONCE IN NEW SCREEN** + + * cd /vagrant/badgekitapi + + * foreman run web + +* Then, Ctrl-A,Ctrl-D will take you back out of that screen + +* To resume, you will want to first find the screen #'s, then resume them + + * screen -ls # This will list the screens. + +* The output of screen -ls looks like this: + + * 2759.pts-0.precise64 (06/05/2014 07:21:47 PM) (Detached) + + * 2701.pts-0.precise64 (06/05/2014 07:21:36 PM) (Detached) + +* To resume the first screen, #2759, use this command + + * screen -r 2759 + +# ACCESSING THROUGH YOUR LOCAL BROWSER DEFAULTS + +* http://localhost:3000 - badgekit.org clone + +* http://localhost:3500 - api.badgekit.org clone + +# ACCESSING UTILITIES FROM LOCAL MACHINE + +* MySQL host: localhost:3306 + +* MySQL user: root / nopassword (blank) + +* MySQL user: badgekit PW: badgekit + +* MySQL user: badgekitapi PW: badgekitapi + diff --git a/README.md b/README.md index 3c2b746..2467772 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ API calls should be signed with a JWT token generated using the secret for your ## Installation -To install the BadgeKit API: +To install the BadgeKit API: * clone the repo * set up a database * set your environment configs. @@ -49,3 +49,9 @@ The BadgeKit API currently uses the following configuration details: * `DB_USER`: User who has full access to the `DB_NAME` table. * `DB_PASSWORD`: Password for the `DB_USER`. * `MASTER_SECRET`: The master secret used to sign global-access JWT tokens. This should not be shared widely – probably only with one front-end, e.g. `badgekit`. + +## Running all Badgekit apps on vagrant + +Please see the README.vagrant.md file for a detailed walk through to setup a fast local dev environment using [Vagrant](http://www.vagrantup.com/) + +This provides a mostly-prebuilt Ubuntu server, complete with MySQL and Node.JS at the correct versions. diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..84d8bef --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,38 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of, specified already in the Vagrantfile + + # This Vagrantfile is Node.js, MySQL setup for badgekit + # As of 1/17/14, this is in rough draft, please submit + # bugs via webmaker :: devops, or email jp@mozillafoundation.org + config.vm.box = "badgekitsuite" + + # The url from where the 'config.vm.box' box will be fetched if it + # doesn't already exist on the user's system. + config.vm.box_url = "http://stuff.webmaker.org/devtools/mofo_vagrant_baseboxes/badgekitsuite.box" + + # Create forwarded port mappings + # Webmaker apps have the following port assignments/urls + # which are opened up to your local workstation by the + # following stanzas + + # Configure mongo and elasticsearch port forwards + + config.vm.network :forwarded_port, guest: 3000, host: 3000 + config.vm.network :forwarded_port, guest: 3500, host: 3500 + config.vm.network :forwarded_port, guest: 3600, host: 3600 + + # Be sure you make this directory wherever you want this + # vagrant instance to run from. + config.vm.synced_folder "./vagrant", "/vagrant" + +end diff --git a/sample.env b/sample.env new file mode 100644 index 0000000..4ed6ffb --- /dev/null +++ b/sample.env @@ -0,0 +1,9 @@ +export PORT=3500 +export PERSONA_AUDIENCE=http://localhost:3500 +export COOKIE_SECRET=blah +export DB_HOST=localhost +export DB_PORT=3306 +export DB_NAME=badgekitapi +export DB_USER=badgekitapi +export DB_PASSWORD=badgekitapi +export MASTER_SECRET=blah \ No newline at end of file