gitenberg-dev / giten_site

django repo for running the GITenberg website
http://www.gitenberg.org
40 stars 5 forks source link

= A Django website for GITenberg

The goal of gitensite is to:

== Set up This is a django/python project, so you are going to want to use some standard python dev tools.

=== environment Copy example.env to .env and store your local db secret and other values there.

Virtual environments in python are a way of separating and reproducing the python package requirements.

From the root of the project

pipenv install -r requirements.txt

For every new terminal, or when returning to work on the project, you will need to run

source venv/bin/activate

=== Database(s) We use Postgres.

To start a local db run:

./manage.py migrate
./manage.py createsuperuser

If you have modified the database, generate new database migrations:

./manage.py makemigrations

And run them with:

./manage.py migrate

==== Getting db data To fill out data in your local db, you'll first need to download and unpack the Project Gutenberg RDF metadata. you can run the provided load_repos management command: from https://www.gutenberg.org/cache/epub/feeds/rdf-files.tar.zip

Then run ./manage.py load_repos

Where <rdf_library_path> is the address where you unzipped the rdf metadata

== Apps

There are currently three apps in the project:

== Elastic Beanstalk this website is deployed on Elastic Beanstalk. Install the awsebcli tool in it's own py 3.7+ environment- it doesn't play well with other packages, even boto from aws!

cd to the project directory and you should be able to deploy updates using

eb deploy [giten-site-new]

Remember to commit changes before deploying.

== Vagrant

To install with Vagrant, follow these steps:

. First install (on the local machine): VirtualBox Vagrant ** Ansible . Then from the project directory run this command:

vagrant up

. Then wait about 2 hours while it does its thing (loading the DB takes a very long time) . To log in:

vagrant ssh

. Once logged in

cd giten_site

+ The virtualenv and environment variables should be automatically loaded upon login.

. Start the server

python manage.py runserver 0.0.0.0:5001

+ Use port 5001 since the Vagrantfile will automatically forward this port to the local port 5001. To use a different port, change the Vagrantfile on the host machine and run vagrant halt and vagrant up. Using the IP 0.0.0.0 will permit django to serve this on any IP. When running in vagrant the webserver doesn't recognize localhost addresses as being from localhost since it is port-forwarded into the virtual machine.

. Go to http://localhost:5001 . Done.