README.md 5.91 KB
Newer Older
David Haynes's avatar
David Haynes committed
1
# Go (URL Shortener) [![build status](https://git.gmu.edu/srct/go/badges/master/build.svg)](https://git.gmu.edu/srct/go/commits/master) [![coverage report](https://git.gmu.edu/srct/go/badges/2.2-dev/coverage.svg)](https://git.gmu.edu/srct/go/commits/2.2-dev)
Jean Michel Rouly's avatar
Jean Michel Rouly committed
2

David Haynes's avatar
David Haynes committed
3
A project of [GMU SRCT](http://srct.gmu.edu).
Jean Michel Rouly's avatar
Jean Michel Rouly committed
4

5 6 7 8
Go is a drop-in URL shortening service. It aims to provide an easily
branded service for institutions that wish to widely disseminate
information without unnecessarily outsourcing branding.

David Haynes's avatar
David Haynes committed
9
I encourage you to join the #go channel in SRCT's [Slack Group](http://srct.slack.com) if you have any questions on setup or would like to contribute.
David Haynes's avatar
David Haynes committed
10

David Haynes's avatar
David Haynes committed
11
## Package Installation
David Haynes's avatar
David Haynes committed
12
<legend></legend>
13

14
### Prerequisities
David Haynes's avatar
David Haynes committed
15
First, install python and git on your system.
16 17 18 19 20 21 22 23 24 25 26
* Python is the programming language used for Django, the web framework used by Go.
* Git is the version control system used for SRCT projects.

Open a terminal and run the following command:

`$ sudo apt-get update`

This retrieves links to the most up-to-date and secure versions of your packages.

Next, with:

27
`$ sudo apt-get install python python-dev python-pip git`
28 29 30

you install python and git.

31
**macOS (Formerly OS X)**
Zosman's avatar
Zosman committed
32

33
This tutorial uses the third party Homebrew package manager for macOS, which allows you to install packages from your terminal just as easily as you could on a Linux based system. You could use another package manager (or not use one at all), but Homebrew is highly reccomended.
Zosman's avatar
Zosman committed
34

35
To get homebrew, run the following command in a terminal: `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)`
Zosman's avatar
Zosman committed
36

37
**Note**: You do NOT need to use `sudo` when running any Homebrew commands, and it likely won't work if you do.
Zosman's avatar
Zosman committed
38

39
Next, to make sure Homebrew is up to date, run `brew update`
Zosman's avatar
Zosman committed
40

41
Finally we can install python and git with `brew install python git`
Zosman's avatar
Zosman committed
42

43 44
### Cloning the Go Codebase
Now, we're going to clone down a copy of the Go codebase from [git.gmu.edu](http://git.gmu.edu/srct/go), the SRCT code respository.
45

David Haynes's avatar
David Haynes committed
46
Configure your ssh keys by following the directions at [git.gmu.edu/help/ssh/README](http://git.gmu.edu/help/ssh/README).
47 48 49 50 51

Now, on your computer, navigate to the directory in which you want to download the project (perhaps one called development/ or something similar), and run

`$ git clone git@git.gmu.edu:srct/go.git`

52
### If Using Docker
53
First, install Docker on your system.
54 55 56
* For macOS go here: https://docs.docker.com/docker-for-mac/
* For windows go here: https://docs.docker.com/docker-for-windows/
* For you specific linux disro go here: https://docs.docker.com/engine/installation/
57

58 59 60
Additionally if you are not on Mac or Windows you will need to install docker-compose: https://docs.docker.com/compose/install/

Next go to the directory with the docker-compose file in it and run:
mdsecurity's avatar
mdsecurity committed
61 62 63

`$ docker-compose up`

Robert Hitt's avatar
Robert Hitt committed
64 65 66 67
If that doesn't work, try:

`$ sudo docker-compose up`

68
SOMETIMES if this branch is updated you might have to 
mdsecurity's avatar
mdsecurity committed
69 70
You should see that the server is running by going to http://localhost:8000 in your browser.
Any changes you make to your local file system will be mirrored in the server.
71

72
### If Using Vagrant
73
Finally, install these packages from the standard repositories:
David Haynes's avatar
David Haynes committed
74 75
 - VirtualBox

76
    On Ubuntu:
David Haynes's avatar
David Haynes committed
77
    `$ sudo apt-get install virtualbox`
78

Zosman's avatar
Zosman committed
79

80
    You should be installing the latest VirtualBox version which as of time of writing is `5.0.24_Ubuntur108355`. You can verify the version number by running `vboxmanage --version`.
81

David Haynes's avatar
David Haynes committed
82 83 84
 - Vagrant

    `$ sudo apt-get install vagrant`
85 86

    You should be installing the latest vagrant version which as of time of writing is `Vagrant 1.8.1`. You can verify the version number by running `vagrant -v`.
David Haynes's avatar
David Haynes committed
87 88
 - Ansible

89 90 91
    `$ sudo pip install ansible`

    You should be installing the latest ansible version which as of time of writing is `ansible 2.1.1.0`. You can verify the version number by running `ansible --version`.
Zosman's avatar
Zosman committed
92

93
  **macOS**
Zosman's avatar
Zosman committed
94

95
  First, get VirtualBox from [VirtualBox.org](https://www.virtualbox.org/wiki/Downloads)
Zosman's avatar
Zosman committed
96

97
  Then install Vagrant and Ansible with Homebrew with `brew install Caskroom/cask/vagrant Ansible`
98 99

## Developing with Vagrant
David Haynes's avatar
David Haynes committed
100 101 102 103 104 105 106 107 108
<legend></legend>
Vagrant allows for the virtualization of your development enviornment and automates the setup process for Go.

### Vagrant Setup
Navigate to go/ and run:

`$ vagrant up`

This will setup a vm to run Go on your computer and will setup a database, install packages, etc. The first time you run `vagrant up` it may take a few minutes to setup, specifically when installing Go packages. Don't worry as progressive times it will speed up.
109

Zosman's avatar
Zosman committed
110
And that's it! Navigate to [localhost:8000](http://127.0.0.1:8000) in your web browser to view the website.
David Haynes's avatar
David Haynes committed
111

112
### Additional Notes & Troubleshooting
David Haynes's avatar
David Haynes committed
113

David Haynes's avatar
David Haynes committed
114 115 116 117
The authentication service used for Go is CAS. In local development however we utilize a test server. You can log in using your CAS username for both the username and password fields.

 The default superuser is _dhaynes3_ though this can be changed in _vagrantfile_ if you wish. You can run `$ vagrant provision` to apply this change. Be sure not to include that change in your commits.

118
*Note:* For a currently undetermined reason at some points if you try to navigate to [localhost](http://127.0.0.1:8000) and you see an error like: "Conenction has been reset" then:
David Haynes's avatar
David Haynes committed
119 120 121
1. `vagrant ssh`
2. `sudo /etc/init.d/networking restart` and then `exit`
3. `vagrant provision` (may need to do twice)
David Haynes's avatar
David Haynes committed
122

David Haynes's avatar
David Haynes committed
123 124 125
This is the only temporary fix that we know exists.

If you make any changes to _models.py_ you will need to re-provision the vm's database:
David Haynes's avatar
David Haynes committed
126 127 128

`$ vagrant provision`

David Haynes's avatar
David Haynes committed
129
Please note that this will refresh the database (as in delete everything in it).
David Haynes's avatar
David Haynes committed
130 131


132 133 134 135 136 137 138
### Cron

In order to expire links, you need to set up a cron job to run the manage.py
expirelinks command regularly. A sample cron script is available in the
repository and is named go-cleanlinks.cron. Drop this in cron.hourly and
change the paths so that they point to the virtualenv activate script and
manage.py.
David Haynes's avatar
David Haynes committed
139 140 141


### Note
142
Link by Viktor Vorobyev from the Noun Project.