Skip to content

Commit

Permalink
Documentation updates (#31)
Browse files Browse the repository at this point in the history
* Update readme.md and create nginx_setup.md

* Add discord link to readme

* Update README.md

* nginx_setup.md initial commit

* re-add start.sh

* Add travis badge to readme. Closes #29

* "Instalation" (Thanks Ben)

* Update README.md

* Update README.md

* remove incomplete tag

* Update nginx_setup.md

* Delete random underscore in start.sh
  • Loading branch information
techlover1 committed Nov 26, 2019
1 parent 329d017 commit 2451b47
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 20 deletions.
72 changes: 52 additions & 20 deletions README.md
@@ -1,30 +1,62 @@
# project-olly
# Project Olly
[![Build Status](https://travis-ci.org/NFM-Studios/project-olly.svg?branch=master)](https://travis-ci.org/NFM-Studios/project-olly)
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors)
<a href="https://discord.gg/5dp8x2t">
<img src="https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat" />
</a>

# About the project
Project Olly is an online esports tournament hosting platform written in Python 3 using the Django web framework. It began as a closed source commercial product until November 2019 when it was re-released under the MPL2.0 license (see license.md)

# Configuration
Copy `olly/settings.py.example` to `olly/settings.py`

In `olly/settings.py` fill in the following fields:
- `SECRET_KEY` - This value is used for django's cryptographic signing functions. You can easily generate this by running `from django.core.management.utils import get_random_secret_key` followed by `get_random_secret_key()` in a django shell (`python manage.py shell`)
- `ALLOWED_HOSTS` - It is strongly recommended to set this to the domain name of your site to prevent HTTP host header attacks
- `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_S3_ENDPOINT_URL` - Authentication information for AWS S3 compatable object storage. Note: this is not required, however we do not currently have documentation on how to setup with local storage
- `AWS_STORAGE_BUCKET_NAME` - This is simply the name you wish to use for your S3 compatable bucket
- `EMAIL_HOST` - The hostname of your email server (for example `smtp.gmail.com`)
- `EMAIL_HOST_USER` and `EMAIL_HOST_PASSWORD` - the login information for your email account
- `FROM_EMAIL` - The name and email address that will be shown in the "From" field in emails
- `GOOGLE_RECAPTCHA_SECRET_KEY` and `GOOGLE_RECAPTCHA_SITE_KEY` - Authentication information for Google reCAPTCHA
- `DEBUG` and `PAYPAL_TEST` - Set to False
- `DATABASES` section - It is highly recommended to use postgresql rather than sqlite for deployment as it has much higher performance. Replace the existing DATABASES section with the one below and edit the information as instructed in the comments
```python
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mydatabase', # The name of the database (must exist)
'USER': 'mydatabaseuser', # The username you wish to use to connect to the database
'PASSWORD': 'mypassword', # The password of the user
'HOST': '127.0.0.1', # The IP address of the database server. If it is the same server, this can be left as is
'PORT': '5432', # The port the database server is running on. It is unlikely you will need to change this
}
}
```

# Installation - without Docker
#### Not officially supported. It is possible, but we aren't able to assist with the installation if you choose to do so.

1. Clone the repository! You need the code, it won't just magically work without it.
2. Install requirements - ensure you already have python3 installed on your machine. We recommend the latest python3.7 build
```pip install -r requirements.txt``` (run that command, assuming you are in the main directory
3. Get a secret key! By default there is no secret key, so be sure to put a secret key in settings.py -
the following lines will have django create a new key for you
`from django.core.management.utils import get_random_secret_key`
`get_random_secret_key()`
4. Apply database migrations by running ```python3 manage.py migrate``` (assuming your database options are set as you'd like in settings.py)
5. If you are utilizing AWS for storage, make sure you obtain the required keys and put them in settings.py
6. If you are looking to enable CAPTCHA for logins, make sure you obtain the required keys and put them in settings.py
as well as profiles/templates/captcha.html - and uncomment the lines in profiles.views that pertain to form verification of the captcha success
7. Be sure to set SMTP email settings in settings.py so account activation emails can be sent out to new users
8. Create a django admin/super user account - ```python manage.py createsuperuser```
9. Give your new superuser account staff panel access by modifying the database row in the `profiles_userprofile` table - set
`user_verified` to `1` and set `user_type` to `superadmin` or `admin`
9. Create a StaticInfo object, if you don't every page will throw an error telling you that it can't access the StaticInfo - easiest
2. Install requirements - `pip install -r requirements.txt`
3. Configure settings.py
4. Apply database migrations by running `python3 manage.py migrate` (assuming your database options are set as you'd like in settings.py)
5. Create a django admin/super user account - `python manage.py createsuperuser` and follow the prompts
6. Give your new superuser account staff panel access by modifying the database row in the `profiles_userprofile` table - set
`user_verified` to `1` and set `user_type` to `superadmin` or `admin` (hint: you can use django admin at /admin)
7. Create a StaticInfo object, if you don't every page will throw an error telling you that it can't access the StaticInfo - easiest
way to make a staticinfo object is through the django admin at /admin
8. Setup a web server and reverse proxy using industry standard best practices (hint: gunicorn and nginx work well)

# Docker Instalation
# Docker Installation

# Configuration
You can and probably should configure things to however you'd like! As a general project we try to make things as flexible as possible
but sometimes we just can't have it do everything in the world :(
1. Clone the repository! You need the code, it won't just magically work without it. (Seems to be a recurring theme)
2. Create the folder for static files by running `sudo mkdir /var/www/static` and transfer ownership by running `sudo chown www-data:www-data /var/www/static`. Feel free to substitute the username, but your reverse proxy must be running as that user
3. Run `docker build .` (take note of the image id) followed by `docker run -d -v /var/www/static:/static -v /tmp:/sock --net=host -u www-data --name project-olly [your image id]`
4. Setup a reverse proxy of your choice (we highly recommend nginx, and have setup instructions available in [nginx_setup.md](nginx_setup.md))
5. A user was automatically created with the username `admin` and the password `ChangeMe!` **DON'T FORGET TO CHANGE THE PASSWORD!**
6. How easy was that!?

# Designs and Template
Project Olly allows you to throw in your front end templates without having to mess with any backend code! It's simple!
Expand Down
46 changes: 46 additions & 0 deletions nginx_setup.md
@@ -0,0 +1,46 @@
# NGINX setup instructions

### Note: This document assumes a Debian or Ubuntu system

## HTTP Setup

1. Install nginx by running `sudo apt install -y nginx`
2. Save the following to `/etc/nginx/sites-available/olly`. Be sure to replace `example.com` with your domain. (This should be the same as `ALLOWED_HOSTS` in `settings.py`.)
```nginx
server {
listen 80;
client_max_body_size 4G;
server_name example.com;
keepalive_timeout 5;
root /var/www/static;
location /static {
alias /var/www/static;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unix:/tmp/olly.sock;
}
}
```
3.Create a symlink in the `sites-enabled` directory to the configuration file you just created `sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled` and restart nginx `sudo nginx -s reload`

## HTTPS setup with Let's Encrypt

After setting up nginx you will likely want to add HTTPS support

1. (Ubuntu only, if you are running Debian skip this step.) Run the following commands to add the certbot PPA
```bash
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
```
2. Install certbot `sudo apt install -y certbot python-certbot-nginx`
3. Configure certbot by running `sudo certbot --nginx` and following the prompts
20 changes: 20 additions & 0 deletions start.sh
@@ -0,0 +1,20 @@
#!/bin/bash
echo Debug is $debug

echo Running Migrations.
python3 manage.py migrate

echo creating a superuser.
python3 manage.py shell -c "from django.contrib.auth import get_user_model; User=get_user_model(); User.objects.filter(pk=1).exists() or User.objects.create_superuser('admin', 'admin@example.com', 'ChangeMe!')"
python3 manage.py shell -c "from profiles.models import UserProfile; up=UserProfile.objects.get(pk=1); up.user_type='superadmin'; up.user_verified=1; up.save()"

echo creating staticinfo
python3 manage.py shell -c "from pages.models import StaticInfo; StaticInfo.objects.get_or_create(pk=1);"

echo Collecting static files
python3 manage.py collectstatic --noinput

echo Starting Gunicorn.
gunicorn olly.wsgi:application \
--bind unix:/sock/olly.sock \
--workers 2

0 comments on commit 2451b47

Please sign in to comment.