Adding some lower bound version number for Vagrant after fighting with version 1...
[oweals/karmaworld.git] / README.md
1 # KarmaWorld
2 __Description__: A django application for sharing and uploading class notes.
3
4 __Copyright__: FinalsClub, a 501c3 non-profit organization
5
6 __License__: GPLv3 except where otherwise noted
7
8 __Contact__: info@karmanotes.org
9
10 v3.0 of the karmanotes.org website from the FinalsClub Foundation
11
12
13
14
15 # Purpose
16
17 KarmaNotes is an online database of college lecture notes.  KarmaNotes empowers college students to participate in the free exchange of knowledge. 
18
19 # Pre-Installation
20
21 Clone the project from the central repo using your github account:
22
23     git clone git@github.com:FinalsClub/karmaworld.git
24
25 If you aren't using a system setup for github, then grab the project with
26 this command instead:
27
28     git clone https://github.com/FinalsClub/karmaworld.git
29
30 Generally speaking, this will create a subdirectory called `karmaworld` under
31 the directory where the `git` command was run. This git repository directory
32 will be referred to herein as `{project_root}`.
33
34 There might be some confusion as the git repository's directory will likely be
35 called `karmaworld` (this is `{project_root}`), but there is also a `karmaworld`
36 directory underneath that (`{project_root}/karmaworld`) alongside files like
37 `fabfile.py` (`{project_root}/fabfile.py`) and `README.md`
38 (`{project_root}/README.md`).
39
40 # Development Install
41
42 If you need to setup the project for development, it is highly recommend that
43 you grab an existing development virtual machine or create one yourself. 
44 Configure the virtual machine for production with the steps shown in the
45 next section (Production Install). Instructions for creating a virtual machine
46 follow:
47
48 1. Install [VirtualBox](http://www.virtualbox.com/)
49
50 1. Install [vagrant](http://www.vagrantup.com/) 1.3 or higher
51
52 1. Use Vagrant to create the virtual machine.
53     * While in `cd {project_root}`, type `vagrant up`
54
55 # Production Install
56
57 If you're starting to work on this project and you need it setup for production,
58 follow the steps below.
59
60 1. Ensure the following are installed:
61    * `git`
62    * `PostgreSQL` (server and client)
63    * `Python`
64    * `PIP`
65    * `virtualenv` and `virtualenvwrapper`
66
67 1. Generate a PostgreSQL database and a role with read/write permissions.
68    * For Debian, these instructions are helpful: https://wiki.debian.org/PostgreSql
69
70 1. Modify configuration files.
71    * There are settings in `{project_root}/karmaworld/settings/dev.py`
72    * There are additional configuration options for external dependencies
73      under `{project_root}/karmaworld/secret/`.
74        * Copy files with the example extension to the corresponding filename
75          without the example extension (e.g.
76          `cp filepicker.py.example filepicker.py`) 
77        * Modify those files.
78            * Ensure `PROD_DB_USERNAME`, `PROD_DB_PASSWORD`, and `PROD_DB_NAME`
79              inside `db_settings.py` match the role, password, and database
80              generated in the previous step.
81        * Ensure *.py in `secret/` are never added to the git repo. (.gitignore
82          should help warn against taking this action)
83
84 1. Make sure that you're in the root of the project that you just cloned and
85    run
86
87         fab here first_deploy
88
89    This will make a virtualenv, install the development dependencies and create
90    the database tables.
91
92 1. Now you can run ``./manage.py runserver`` and visit the site in the browser.
93
94 # Accessing the Vagrant Virtual Machine
95
96 ## Connecting to the VM via SSH
97 If you have installed a virtual machine using `vagrant up`, you can connect
98 to it by running `vagrant ssh` from `{project_root}`.
99
100 ## Connecting to the development website on the VM
101 To access the website running on the VM, point your browser at
102 http://localhost:6659/ using your host computer.
103
104 Port 6659 on your local machine is set to forward to the VM's port 80.
105
106 Fun fact: 6659 was chosen because of OM (sanskrit) and KW (KarmaWorld) on a
107 phone: 66 59.
108
109 ## Updating the VM code repository
110 Once connected to the virtual machine by SSH, you will see `karmaworld` in
111 the home directory. That is the `{project_root}` in the virtual machine.
112
113 `cd karmaworld` and then use `git fetch; git merge` and/or `git pull origin` as
114 desired.
115
116 The virtual machine's code repository is set to use your host machine's
117 local repository as the origin. So if you make changes locally and commit them,
118 without pushing them anywhere, your VM can pull those changes in for testing.
119
120 This may seem like duplication. It is. The duplication allows your host machine
121 to maintain git credentials and manage repository access control so that your
122 virtual machine doesn't need sensitive information. Your virtual machine simply
123 pulls from the local repository on your local file system without needing
124 credentials, etc.
125
126 ## Other Vagrant commands
127 Please see [vagrant documentation](http://docs.vagrantup.com/v2/cli/index.html)
128 for more information on how to use the vagrant CLI to manage your development
129 VM.
130
131 Thanks
132 ======
133
134 * KarmaNotes.org is a project of the FinalsClub Foundation with generous funding from the William and Flora Hewlett Foundation
135
136 * Also thanks to [rdegges](https://github.com/rdegges/django-skel) for the django-skel template