Commit 79a28ba3 authored by Julius Ahenkora's avatar Julius Ahenkora

Merge branch '2.3-dev' into 151-ReadMeTypo

parents e91388ec 09429742
Pipeline #1652 passed with stages
in 2 minutes and 32 seconds
go/settings/settings.py
go/settings/secret.py
docker-compose.yml
**/*.pyc
Dockerfile
Vagrantfile
.dockerignore
\ No newline at end of file
......@@ -57,7 +57,7 @@ Go-py3.6:
image: library/python:3.6
stage: test
script:
- if pip list --outdated | grep "Latest" | wc -l > 0; then pip list --outdated && exit 1; else exit 0; fi
# - if pip list --outdated | grep "Latest" | wc -l > 0; then pip list --outdated && exit 1; else exit 0; fi
- coverage run --source=go --omit=*migrations/*,*admin.py,*manage.py,*wsgi.py,*settings.py,*secret.py,*__init__.py,*.pyc,*templates/*,*static/* manage.py test
- coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}'
......
# Build on top of the python image and install any external packages
FROM python:3.6
ENV PYTHONUNBUFFERED 1
RUN apt-get update
RUN apt-get install netcat -y
RUN mkdir /go
WORKDIR /go
ADD /requirements/ /go/
RUN pip install -r base.txt
# Set enviornment variables
ENV PYTHONUNBUFFERED 1
# Copy over all project files into /go/
RUN mkdir /go/
WORKDIR /go/
ADD . /go/
# Install pip dependecies
RUN pip install -r /go/requirements/dev.txt
......@@ -15,8 +15,7 @@ Django 2.0 in December 2017) project written in the `Django` web framework, with
# Setup instructions for local development
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
the Docker container platform. We have included instructions for manual setup as well. Here's our walk-through
of steps we will take:
1. Install `git` on your system.
......@@ -72,7 +71,6 @@ Windows Subsystem for Linux (WSL). The following link should get you up and runn
[https://msdn.microsoft.com/en-us/commandline/wsl/install_guide](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide)
#### Contributing with Windows
After that is setup, you should be able to follow the Linux instructions for _manual setup_ to
......@@ -83,11 +81,8 @@ Windows here:
[https://git-scm.com/download/win](https://git-scm.com/download/win)
You'll want to follow the Vagrant setup method as it is designed to run on all platforms
including Windows.
I have also successfully ran the project with Docker, though you need
access to Hyper-V which is only available on "Professional" versions of Windows.
I have successfully ran the project with Docker, though you need access to
Hyper-V which is only available on "Professional" versions of Windows.
## 2) Clone the Go codebase.
......@@ -117,7 +112,7 @@ 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.
processes to the OS.
Check out [docker.com](https://www.docker.com/what-docker) for more details.
......@@ -127,8 +122,7 @@ Pros:
- 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.
- Compared to other methods, Docker is comparatively faster to setup than manual setup.
- Minimal setup
- You run one command. Really easy to get up and running once you install
Docker.
......@@ -138,50 +132,13 @@ Pros:
- Can easily destroy and rebuild the docker images
- Loads in changes to code on the fly
Cons:
- Challenging to debug problems
- Cannot interact with attached images and as a result, you cannot really
interact with the database.
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).
### 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).
### Manual Setup
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.
doing that with Docker except it automates the steps that are laid out in this section.
Pros:
- Experience setting up a Django project for local development
......@@ -215,16 +172,6 @@ rely on. Here's how to run them locally:
Docker is not supported currently for running unit tests. If you're able to get
it set up, open a merge request and I'll merge it in.
#### Vagrant
vagrant up
vagrant ssh
cd /vagrant
source venv/bin/activate
cd go
source sourceme.sh
python manage.py test
#### Manual Setup
Assuming you are within your virtualenv:
......@@ -253,9 +200,9 @@ use the same username and Full Name as your main account and select "approved" i
## Coding style
You should adhere to the style of the repo code. Consistancy is key! PEP8 guidelines
are strongly reccomended but not enforced at the time. Please comment your code,
I will not accept commits that contain uncommented code.
You should adhere to the style of the repo code. Consistency is key! PEP8 guidelines
are strongly recommended but not enforced at the time. Please comment your code,
I will not accept commits that contain undocumented code.
## Getting Help
......
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Import securerandom for secret key generation
require 'securerandom'
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/trusty64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 8000, host: 8000
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
config.vm.provision "ansible", run: "always" do |ansible|
ansible.playbook = "provisioning/playbook.yml"
ansible.sudo = true
ansible.extra_vars = {
nginx: {
port: 8000,
https: false
},
mysql: {
root_user: "root",
root_pass: "",
user: "go",
pass: "go",
db: "go"
},
django: {
secret_key: SecureRandom.base64,
host: "*",
debug: "True",
email_domain: "@masonlive.gmu.edu",
requirements_path: "/vagrant/requirements.txt",
venv_path: "/vagrant/venv",
cas_url: "https://cas.srct.gmu.edu/",
app_path: "/vagrant/go",
sourceme_dest: "/vagrant/go/",
superuser: "dhaynes3"
}
}
end
=begin
# Picks up from any failed runs
# Run this with: "vagrant provision --provision-with resume"
config.vm.provision "resume", type: "ansible" do |resume|
resume.playbook = "provisioning/playbook.yml"
resume.limit = "@provisioning/playbook.retry"
resume.sudo = true
resume.extra_vars = {
nginx: {
port: 8000,
https: false
},
mysql: {
root_user: "root",
root_pass: "",
user: "go",
pass: "go",
db: "go"
},
django: {
secret_key: SecureRandom.base64,
host: "*",
debug: "True",
email_domain: "@masonlive.gmu.edu",
requirements_path: "/vagrant/requirements.txt",
venv_path: "/vagrant/venv",
cas_url: "https://cas.srct.gmu.edu/",
app_path: "/vagrant/go",
settings_path: "/vagrant/go/settings",
superuser: "dhaynes3"
}
}
end
=end
end
version: '2'
version: "3"
services:
db:
image: mysql
deploy:
replicas: 1
restart_policy:
condition: on-failure
networks:
- gonet
ports:
- "3306:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: go
MYSQL_USER: go
MYSQL_PASSWORD: go
web:
build: .
restart: always
image: go_web
deploy:
replicas: 1
restart_policy:
condition: on-failure
networks:
- gonet
ports:
- '8000:8000'
command: /bin/bash ./startup.sh -python go/manage.py runserver 0.0.0.0:8000
......@@ -27,10 +48,5 @@ services:
- GO_EMAIL_TO=
- superuser=dhaynes3
db:
image: mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: go
MYSQL_USER: go
MYSQL_PASSWORD: go
networks:
gonet:
......@@ -6,7 +6,7 @@
<a href="http://srct.gmu.edu/">GMU<strong> SRCT</strong></a>. |
Read and contribute to our <a href="https://git.gmu.edu/srct/go/">source code</a>. |
Freely-licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. |
Go Version 2.2.3
Go Version 2.3-DEV
</span>
</div>
......@@ -21,7 +21,7 @@
Freely-licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>.
</div>
<div class="col-sm-4 text-muted">
Go Version 2.2.3
Go Version 2.3-DEV
</div>
</div>
</footer>
......@@ -15,7 +15,7 @@ from .base import *
# Do not have set True in production
DEBUG = True
CAS_SERVER_URL = "https://login.gmu.edu/login"
CAS_SERVER_URL = "https://cas.srct.gmu.edu/"
# dummy cache for development-- doesn't actually cache things
CACHES = {
......
---
# Ansible Playbook for Go
#
# Installs a production-like envrionment with:
# - MySQL
# - nginx
# - uwsgi + Emperor
# - Django
- hosts: all
environment:
GO_SECRET_KEY: "{{ django['secret_key'] }}"
GO_ALLOWED_HOSTS: "{{ django['host'] }}"
GO_EMAIL_DOMAIN: "{{ django['email_domain'] }}"
GO_CAS_URL: "{{ django['cas_url'] }}"
GO_DB_NAME: "{{ mysql['db'] }}"
GO_DB_USER: "{{ mysql['user'] }}"
GO_DB_PASSWORD: "{{ mysql['pass'] }}"
GO_DB_HOST: localhost
GO_DB_PORT: 3306
GO_EMAIL_HOST: ""
GO_EMAIL_PORT: ""
GO_EMAIL_HOST_USER: ""
GO_EMAIL_HOST_PASSWORD: ""
GO_EMAIL_FROM: ""
GO_EMAIL_TO: ""
tasks:
- name: Install Python 3.4.3 and related packages
apt:
name: "{{ item }}"
update_cache: yes
state: present
with_items:
- python3
- python3-dev
- python3-pip
- git
- name: Move pip
command: mv /usr/bin/pip3 /usr/bin/pip
ignore_errors: true
- name: Install virtualenv
pip:
name: virtualenv
- name: Create the virtualenv
command: virtualenv -p python3 /vagrant/venv
ignore_errors: true
- name: Install go packages
apt:
name: "{{ item }}"
state: latest
update_cache: yes
with_items:
- mysql-server
- mysql-client
- libmysqlclient-dev
- python-mysqldb
- name: install site packages to virtual env
pip:
requirements: "{{ django['requirements_path'] }}"
virtualenv: "{{ django['venv_path'] }}"
virtualenv_python: /usr/bin/python3
- name: create mysql user
mysql_user:
name: "{{ mysql['user'] }}"
password: "{{ mysql['pass'] }}"
login_password: "{{ mysql['root_pass'] }}"
login_user: "{{ mysql['root_user'] }}"
state: present
host: localhost
priv: "{{ mysql['db'] }}.*:ALL"
- name: create mysql database
mysql_db:
name: "{{ mysql['db'] }}"
state: present
login_user: "{{ mysql['root_user'] }}"
login_password: "{{ mysql['root_pass'] }}"
- name: give mysql user access to test db
mysql_user:
name: "{{ mysql['user'] }}"
login_password: "{{ mysql['root_pass'] }}"
login_user: "{{ mysql['root_user'] }}"
state: present
host: localhost
priv: test_{{ mysql['db'] }}.*:ALL
append_privs: yes
- name: setup django database
django_manage:
command: "{{ item }}"
app_path: "{{ django['app_path'] }}"
virtualenv: "{{ django['venv_path'] }}"
with_items:
- flush
- makemigrations
- makemigrations go
- migrate
- name: create python superuser (defaults to dhaynes3)
django_manage:
command: "createsuperuser --noinput --username={{ django['superuser'] }} --email={{ django['superuser'] }}@masonlive.gmu.edu"
app_path: "{{ django['app_path'] }}"
virtualenv: "{{ django['venv_path'] }}"
- name: killing old screen sessions
shell: screen -ls | grep -q django && screen -X -S django quit
ignore_errors: true
- name: install env variable convenience script
template:
src: templates/sourceme.j2
dest: "{{ django['sourceme_dest'] }}/sourceme.sh"
backup: yes
- name: start django runserver (access via localhost:8000)
command: screen -dmS django bash -c "echo Starting on port {{ nginx['port'] }}; cd /vagrant/go; source ../venv/bin/activate; python3 manage.py runserver 0.0.0.0:8000;"
export GO_SECRET_KEY="{{ django['secret_key'] }}"
export GO_ALLOWED_HOSTS="{{ django['host'] }}"
export GO_EMAIL_DOMAIN="{{ django['email_domain'] }}"
export GO_CAS_URL="{{ django['cas_url'] }}"
export GO_DB_NAME="{{ mysql['db'] }}"
export GO_DB_USER="{{ mysql['user'] }}"
export GO_DB_PASSWORD="{{ mysql['pass'] }}"
export GO_DB_HOST=localhost
export GO_DB_PORT=3306
export GO_EMAIL_HOST=
export GO_EMAIL_PORT=
export GO_EMAIL_HOST_USER=
export GO_EMAIL_HOST_PASSWORD=
export GO_EMAIL_FROM=
export GO_EMAIL_TO=
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment