README.md 6.5 KB
Newer Older
David Haynes's avatar
David Haynes committed
1
# Go
Jean Michel Rouly's avatar
Jean Michel Rouly committed
2

3
[![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/master/coverage.svg)](https://git.gmu.edu/srct/go/commits/master) [![python version](https://img.shields.io/badge/python-2.7-blue.svg)]() [![Django version](https://img.shields.io/badge/Django-1.10-brightgreen.svg)]()
Jean Michel Rouly's avatar
Jean Michel Rouly committed
4

David Haynes's avatar
David Haynes committed
5
#### A project of [GMU SRCT](http://srct.gmu.edu).
6

David Haynes's avatar
David Haynes committed
7 8 9
Go is a drop-in URL shortening service. This project aims to provide an easy to use
URL branding service for institutions that wish to widely disseminate information
without unnecessarily outsourcing branding.
David Haynes's avatar
David Haynes committed
10

David Haynes's avatar
David Haynes committed
11 12
Go is currently a `Python 2.7` project written in the `Django` web framework, with
`MySQL` as our backend database.
13

David Haynes's avatar
David Haynes committed
14
# Setup instructions for local development
15

David Haynes's avatar
David Haynes committed
16 17 18 19
Go currently supports developers on Linux, macOS and Windows platforms through
both the Docker and Vagrant virtualization platforms. You may use either one
though we have included instructions for manual setup as well. Here's our walk-through
of steps we will take:
20

David Haynes's avatar
David Haynes committed
21 22 23
1. Install `git` on your system.
2. Clone the Go codebase.
3. Get Go up and running with the method of your choice.
Zosman's avatar
Zosman committed
24

David Haynes's avatar
David Haynes committed
25
## 1) Install `git` on your system.
Zosman's avatar
Zosman committed
26

David Haynes's avatar
David Haynes committed
27
`git` is the version control system used for SRCT projects.
Zosman's avatar
Zosman committed
28

David Haynes's avatar
David Haynes committed
29
### On Linux Based Systems
Zosman's avatar
Zosman committed
30

David Haynes's avatar
David Haynes committed
31 32
**with apt:**

David Haynes's avatar
David Haynes committed
33
Open a terminal and run the following command:
mdsecurity's avatar
mdsecurity committed
34

David Haynes's avatar
David Haynes committed
35
    sudo apt update
Robert Hitt's avatar
Robert Hitt committed
36

David Haynes's avatar
David Haynes committed
37
This retrieves links to the most up-to-date and secure versions of your packages.
Robert Hitt's avatar
Robert Hitt committed
38

David Haynes's avatar
David Haynes committed
39
Next, with:
40

David Haynes's avatar
David Haynes committed
41
    sudo apt install git
David Haynes's avatar
David Haynes committed
42

David Haynes's avatar
David Haynes committed
43
you install `git` onto your system.
44

David Haynes's avatar
David Haynes committed
45 46 47 48 49 50
**with yum (now something else??):**

**with rpm:**

**with other package manager???:**

David Haynes's avatar
David Haynes committed
51
### On macOS
Zosman's avatar
Zosman committed
52

David Haynes's avatar
David Haynes committed
53 54 55 56
We recommend that you use 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.
57

David Haynes's avatar
David Haynes committed
58
To get homebrew, run the following command in a terminal:
David Haynes's avatar
David Haynes committed
59

David Haynes's avatar
David Haynes committed
60
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
61

David Haynes's avatar
David Haynes committed
62 63
**Note**: You do NOT need to use `sudo` when running any Homebrew commands, and
it likely won't work if you do.
David Haynes's avatar
David Haynes committed
64

David Haynes's avatar
David Haynes committed
65
Next, to make sure Homebrew is up to date, run:
66

David Haynes's avatar
David Haynes committed
67
    brew update
Zosman's avatar
Zosman committed
68

David Haynes's avatar
David Haynes committed
69 70 71
Finally we can install git with:

    brew install git
Zosman's avatar
Zosman committed
72

David Haynes's avatar
David Haynes committed
73
### On Windows
David Haynes's avatar
David Haynes committed
74

David Haynes's avatar
David Haynes committed
75
Instructions on how to setup git on Windows goes here.
Zosman's avatar
Zosman committed
76

David Haynes's avatar
David Haynes committed
77
## 2) Clone the Go codebase.
David Haynes's avatar
David Haynes committed
78

David Haynes's avatar
David Haynes committed
79
Now, we're going to clone down a copy of the Go codebase from [git.gmu.edu](http://git.gmu.edu/srct/go),
David Haynes's avatar
David Haynes committed
80 81 82
the SRCT code respository with SSH.

**a)** Configure your ssh keys by following the directions at:
83

David Haynes's avatar
David Haynes committed
84
[git.gmu.edu/help/ssh/README](http://git.gmu.edu/help/ssh/README).
David Haynes's avatar
David Haynes committed
85

David Haynes's avatar
David Haynes committed
86
**b)** Now, on your computer, navigate to the directory in which you want to download the project (ie. perhaps one called `development/SRCT`), and run
David Haynes's avatar
David Haynes committed
87

David Haynes's avatar
David Haynes committed
88
    git clone git@git.gmu.edu:srct/go.git
David Haynes's avatar
David Haynes committed
89

David Haynes's avatar
David Haynes committed
90
## 3) Get Go up and running with the method of your choice.
91

David Haynes's avatar
David Haynes committed
92 93 94 95 96 97
Now that we have `git` setup and cloned down the code you can

    cd go/

and get to working on setting up a development environment!

David Haynes's avatar
David Haynes committed
98
### Docker
David Haynes's avatar
David Haynes committed
99

David Haynes's avatar
David Haynes committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
Docker is an emerging containerization platform written in Google's Go
language.
Instead of running a full VM that runs Go, we package up all the
various bits that make up Go and run that as a container (two
containers: one for Go and the other for mysql) that act as normal
processes to the OS.   

Pros:

 - Lightweight
    - Can be run on most machines without needing significant resources.
    - SRCT members report minimal battery impact on laptops.
 - Fast
    - Compared to other methods, Docker is comparatively faster than
    Vagrant or manual setup.
 - Minimal setup
    - You run one command. Really easy to get up and running once you install
    Docker.
 - Good cross platform support
    - Runs smoothly on macOS, Linux, and Windows
    - Great docs to help if you get stuck.
 - Can easily destroy and rebuild the docker images
 - Loads in changes to code on the fly

Cons:
David Haynes's avatar
David Haynes committed
125

David Haynes's avatar
David Haynes committed
126 127 128
 - Challenging to debug problems
    - Cannot interact with attached images and as a result, you cannot really
    interact with the database.
David Haynes's avatar
David Haynes committed
129

David Haynes's avatar
David Haynes committed
130
There are instructions on how to setup/develop with Docker at the [docker-configuration page in the Go project wiki](https://git.gmu.edu/srct/go/wikis/docker-configuration).
David Haynes's avatar
David Haynes committed
131

David Haynes's avatar
David Haynes committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
### Vagrant + Ansible

Vagrant boots up a full virtual machine (VM) through VirtualBox that then runs Go. A
script written with Ansible will then run on that VM to automate the setup process
for you. It is similar in a way to running Go on a legitimate server.

Pros:

  - Very similar to a production environment
  - Can use `vagrant ssh` to "ssh" into the VM to debug things such as the
    database.
  - Relatively straightforward and easy setup.
    - One Command.
  - Can easily destroy and rebuild the VM.
  - Loads in changes to code on the fly.
  - Fast-ish (Initial provision takes a bit).

Cons:

  - Heavier on resources.
    - It's literally a full VM.
  - Occasional issues/hiccups.
    - Documented fixes are in the wiki.

There are instructions on how to setup with Vagrant at the [vagrant-configuration
page in the Go project wiki](https://git.gmu.edu/srct/go/wikis/vagrant-configuration).

Additionally, there is documentation about developing with Vagrant at
the [vagrant-usage page in the Go project wiki](https://git.gmu.edu/srct/go/wikis/vagrant-usage).
David Haynes's avatar
David Haynes committed
161

David Haynes's avatar
David Haynes committed
162
### Manual Setup
David Haynes's avatar
David Haynes committed
163

David Haynes's avatar
David Haynes committed
164 165 166 167 168 169 170 171 172 173 174
Manual setup (or: the old fashioned way) is where you install all dependecies on
your system and run Go as a local server with Django. Granted you are technically
doing that with Vagrant and Docker except those platforms automate the steps that
are laid out in this section.

Pros:
  - Experience setting up a Django project for local development

Cons:
  - Greater potential for things to go wrong
  - Way more steps
David Haynes's avatar
David Haynes committed
175

David Haynes's avatar
David Haynes committed
176 177 178 179 180
Link to wiki page goes here.

# Some words about contributing to Go.

Words about contributing.md go here.
David Haynes's avatar
David Haynes committed
181

David Haynes's avatar
David Haynes committed
182 183
I encourage you to join the [#go channel](https://srct.slack.com/messages/go/details/) in SRCT's [Slack Group](https://srct.slack.com)
if you have any questions on setup or would like to contribute.
David Haynes's avatar
David Haynes committed
184 185


David Haynes's avatar
David Haynes committed
186 187 188
# Some words about deploying Go.

someone @sysadmin writes up about how to deploy Go or just links to the wiki.
189 190 191 192 193 194

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
195

David Haynes's avatar
David Haynes committed
196 197
---
**Note:**
David Haynes's avatar
David Haynes committed
198

199
Link by Viktor Vorobyev from the Noun Project.