Ensure that Yeoman, Grunt and Bower are installed.
-
First install Yeoman:
npm install -g yo
-
Next install Grunt and Bower:
npm install -g grunt-cli bower
-
Then install Node and Bower dependencies:
npm install && bower install
-
Finally the app is ready to be built:
grunt build && grunt server:dist
- First install Pip
sudo easy_install pip
- Next, install virtualenv and virtualenvwrapper
sudo pip install virtualenv
&sudo pip install virtualenvwrapper
- Open up your .bash_profile or .profile (on all recent macs it is the .bash_profile and it is located at ~/.bash_profile), and after your PATH statement, add the following
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
if [[ -r /usr/local/bin/virtualenvwrapper.sh ]]; then
source /usr/local/bin/virtualenvwrapper.sh
else
echo "WARNING: Can't find virtualenvwrapper.sh"
fi
- Now make sure you reload the your profile by doing a
source ~/.bash_profile
orsource ~/.profile
- Open a new terminal window. You should see virtualenvwrapper.sh being run and setting up your .virtualenvs directory.
- Test creating a new virtualenv
mkvirtualenv apitizr
- You should see something in the console like
New python executable in dindintonight/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/< mac username >/.virtualenvs/dindintonight/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/< mac username >/.virtualenvs/dindintonight/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/< mac username >/.virtualenvs/dindintonight/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/< mac username >/.virtualenvs/dindintonight/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/< mac username >/.virtualenvs/dindintonight/bin/get_env_details
- Now after getting it all setup you can now perform a
workon dindintonight
to specify that you want to work on the virtual enviroment for the site. You can perform adeactivate
when you are finished working on the enviroment. - Now we need to setup a record in our hosts file to transform any requests from local.dindintonight.co to transfer it to localhost or 127.0.0.1
- Open up your hosts file by running this
vim /private/etc/hosts
then you are going to add this to the bottom of it
###########################
# DinDinTonight
###########################
# Local DinDinTonight
127.0.0.1 local.apitizr.com
- Now we need to setup a command in our bash profile to run start our django server and also to install any requirements that may have changed. Open up your .bash_profile or .profile (on all recent macs it is the .bash_profile and it is located at ~/.bash_profile), and at the end of the file, add the following (making sure to change anything that is required below)
What the commands look like broken down and the explanations of what they do
sudo ipfw flush; # this will flush out all existing custom firewall rules that may exist in the system firewall
sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to any 80 in; # add a firewall rule that will forward anything coming in on port 80 to port 8080
workon apitizr; # change the virtual enviroment to apitizr
export DJANGO_SETTINGS_MODULE=core.settings.local; # export out what the settings file is that we are going to load for the dev server
export APITIZR_DJANGO_SECRET=buy-some-apitizr-now; # set the secret key which we use for debugging (this can be anything)
cd /PATH/TO/THE/APITIZR; # change directory to the path that the apitizr git repo is at
pip install -r requirements/local.txt; # now install any requirements or update them with any libraries that are required
python manage.py syncdb; # tell django that we want to sync the db so we are working with the latest and greatest
python manage.py runserver local.apitizr.com:8080; # now fire up the server and run it on port 8080 (which if we remember will get anything from port 80)
What it looks like all together
alias apitizr='sudo ipfw flush;sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to any 80 in;workon apitizr;export DJANGO_SETTINGS_MODULE=core.settings.local;export APITIZR_DJANGO_SECRET=buy-some-apitizr-now;cd /PATH/TO/THE/APITIZR;pip install -r requirements/local.txt;python manage.py syncdb;python manage.py runserver local.apitizr.com:8080;'
And lastly add the celery launcher (make sure that the path is correct to the repo)
alias apitizr_celery="cd /Users/rob/Documents/GitHub/DoubleClickDetroit/dindintonight/;workon apitizr;celery worker --app=core -l info;"
- Now make sure you reload the your profile by doing a
source ~/.bash_profile
orsource ~/.profile
, once you have done that you can now call anywheredidintonight
and it will launch your django server and also make sure you are running the latest librarys and also will sync any db changes that are needed
clean:
grunt clean
test specs with Jasmine:
grunt test
build:
grunt build
server for dev:
grunt server
server for dist:
grunt build && grunt server:dist