Mod site for KSP
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 341 commits ahead of KerbalStuff:master.
StollD Merge pull request #183 from HebaruSan/patch-2
In CKAN pull requests, put description last, on a new line
Latest commit b4d9d0f Feb 15, 2018
Permalink
Failed to load latest commit information.
.github Move to .github folder Feb 19, 2016
KerbalStuff Put description last, on a new line Feb 14, 2018
alembic Drop ksp_version in favour of gameversion_Id Apr 8, 2016
config Add some example configs Jun 18, 2014
docker Update spacedock.conf Feb 25, 2016
emails Drop ksp_version in favour of gameversion_Id Apr 8, 2016
images changed fav icons again Apr 7, 2016
scripts Drop ksp_version in favour of gameversion_Id Apr 8, 2016
styles Fix font path Apr 21, 2016
templates Move edit_pack.js to end of import list Mar 18, 2017
.dockerignore Added a dockerignore file so that our container doesn't end up with u… Feb 17, 2016
.gitignore No. Apr 4, 2016
CONTRIBUTING.md Fixed some spelling in CONTRIBUTING.md Feb 19, 2016
Dockerfile Added new system dependency for bcrypt Feb 21, 2016
LICENSE some chnages to the textfiles to make sure noone is copying the logo … Apr 5, 2016
README.md some chnages to the textfiles to make sure noone is copying the logo … Apr 5, 2016
README_DOCKERFILE.md Correcting typo in readme Feb 22, 2016
THANKS some chnages to the textfiles to make sure noone is copying the logo … Apr 5, 2016
admin.py Implement registration flow Jun 2, 2014
alembic.ini.example Cleaned up DB initialization and added a DB password Feb 21, 2016
api.md Drop ksp_version in favour of gameversion_Id Apr 8, 2016
app.py Added a new compose file with a nginx container for serving static files Feb 23, 2016
config.ini.example Add SpaceDock-Notify support Apr 23, 2016
config.py Initial commit Jun 1, 2014
db_initialize.py Hide ?<Game=blah> after creating a mod. May 5, 2016
docker-compose-deploy.yml Update docker-compose-deploy.yml Feb 26, 2016
docker-compose.yml Added ability to toggle between using Flask's debug server and gunico… Feb 22, 2016
import-ckan.py Migrate mod backgrounds from MediaCrush Feb 8, 2015
migrate-backgrounds.py Migrate mod backgrounds from MediaCrush Feb 8, 2015
migrate-profiles.py Migrate user profile backgrounds from MediaCrush Feb 8, 2015
more_fix_stuff.patch fixed input field not showing in "other license" at create mod Apr 14, 2016
oauth.md Implement Google oauth Feb 7, 2016
order_versions.py Add backend chnages for more flexible versions Jul 18, 2014
requirements.txt Add thumbnail support Mar 6, 2016
restart.sh fixed input field not showing in "other license" at create mod Apr 14, 2016

README.md

SpaceDock

Website engine for Kerbal Space Program mods.

http://www.spacedock.info

Installation

Quick overview:

  1. Install Python 3, node.js, virtualenv, PostgreSQL
  2. Set up aforementioned things
  3. Clone KerbalStuff repository
  4. Activate the virtualenv
  5. Install pip requirements
  6. Install coffeescript
  7. Configure KerbalStuff
  8. SQL
  9. Site configuration

Install the dependencies

You'll need these things:

  • Python 3
  • Node.js
  • virtualenv
  • PostgreSQL
  • Redis

Use the packages your OS provides, or build them from source.

Set up services

Do a quick sanity check on all of those things.

$ python3 --version
  Python 3.4.1
$ node --version
  v0.10.29
$ npm --version
  1.4.14
$ pip --version
  pip 1.5.6 from /usr/lib/python3.4/site-packages (python 3.4)
$ virtualenv --version
  1.11.6
$ psql --version
  psql (PostgreSQL) 9.3.4
$ redis-cli --version
  redis-cli 3.0.1

YMMV if you use versions that differ from these.

I'll leave you to set up PostgreSQL however you please. Prepare a connection string that looks like this when you're done:

postgresql://username:password@hostname:port/database

The connection string I use on localhost is this:

postgresql://postgres@localhost/kerbalstuff

KerbalStuff needs to be able to create/alter/insert/update/delete in the database you give it.

You also need to start up redis on the default port if you want to send emails.

Clone SpaceDock

Find a place you want the code to live.

$ git clone git://github.com/KSP-SpaceDock/KerbalStuff.git
$ cd KerbalStuff

Activate virtualenv

$ virtualenv -p python3 --no-site-packages .
$ source bin/activate

If you're like me and are on a system where python3 is not the name of your Python executable, add --python=/path/to/python3 to the virtualenv command to fix that.

pip requirements

$ pip install -r requirements.txt

CoffeeScript

# npm install coffee-script
$ coffee # Sanity check, press ^D to exit

Configure SpaceDock

$ cp alembic.ini.example alembic.ini
$ cp config.ini.example config.ini

Edit config.ini and alembic.ini to your liking.

Postgres Configuration

Depending on your environment, you may need to tell postgres to trust localhost connections. This setting is in the pg_hba.conf file, usually located in /etc/postgresql/[version]/main/. An example of what the config should look like:

local   all    all                    trust
host    all    all    127.0.0.1/32    trust
host    all    all    ::1/128         trust    #may or may not be needed for IPv6 aware installs

Site Configuration

What you do from here depends on your site-specific configuration. If you just want to run the site for development, you can source the virtualenv and run

python app.py

To run it in production, you probably want to use gunicorn behind an nginx proxy. There's a sample nginx config in the configs/ directory here, but you'll probably want to tweak it to suit your needs. Here's how you can run gunicorn, put this in your init scripts:

/path/to/SpaceDock/bin/gunicorn app:app -b 127.0.0.1:8000

The -b parameter specifies an endpoint to use. You probably want to bind this to localhost and proxy through from nginx. I'd also suggest blocking the port you choose from external access. It's not that gunicorn is bad, it's just that nginx is better.

To get an admin user you have to register a user first and then run this (replace <username> with your username):

source bin/activiate
python

from KerbalStuff.objects import *
from KerbalStuff.database import db
u = User.query.filter(User.username == "<username>").first()
u.admin = True
u.confirmation = None
db.commit()

When running in a production enviornment, run python app.py at least once and then read the SQL stuff below before you let it go for good.

Emails

If you want to send emails (like registration confirmation, mod updates, etc), you need to have redis running and then start the Kerbal Stuff mailer daemon. You can run it like so:

celery -A KerbalStuff.celery worker --loglevel=info

Of course, this only works if you've filled out the smtp options in config.ini and you have sourced the virtualenv.

SQL Stuff

We use alembic for schema migrations between versions. The first time you run the application, the schema will be created. However, you need to tell alembic about it. Run the application at least once, then:

$ cd /path/to/SpaceDock/
$ source bin/activate
$ python
>>> from alembic.config import Config
>>> from alembic import command
>>> alembic_cfg = Config("alembic.ini")
>>> command.stamp(alembic_cfg, "head")
>>> exit()

Congrats, you've got a schema in place. Run alembic upgrade head after pulling the code to update your schema to the latest version. Do this before you restart the site.