- sudo apt-get install memcached libmemcached-dev
-
sudo apt-get install python3-pip
-
mkvirtualenv nsfwchecker -p /usr/bin/python3.5
-
workon nsfwchecker
-
postactivate:
- export DJANGO_SETTINGS_MODULE=nsfwchecker.prod_settings
- export DATABASE_URL=postgres://username:userpass@localhost/nsfwchecker
- export DJANGO_DEBUG=True
- export DJANGO_LOCAL=True
- alias python=python3.5
-
postdeactivate:
- alias python=python2.7
-
deactivate
-
workon nsfwchecker
- python --version (should be Python 3.5)
- pip install -r requirements.txt
Run following commands to set up database and user:
# log in to the database
psql -U postgres postgres -h localhost
# In postgres shell
CREATE DATABASE nsfwchecker;
CREATE USER myprojectuser WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE nsfwchecker TO myprojectuser;
Run optionally
ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE myprojectuser SET timezone TO 'UTC';
python manage.py migrate
python manage.py runserver
Make sure environment settings are set correctly in nsfwchecker/deploy_settings.py
, ENVIRONMENTS dictionary.
To deploy latest changes run fab <env_name> deploy
, where env_name is set in the ENVIRONMENTS dictionary.
Install vagrant and virtualbox as a VM backend for it.
Run virtual machine with initial provisionin via running vagrant up
in the root repo dir. If deploying the first time run fab vagrant first_time_deploy
to install the required dependencies, set-up the database and virtual environments.
Useful vagrant commands
# Run deployment once again
fab vagrant deploy
# Shut down running virtual machine
vagrant halt
# Delete machine with launched installation (e.g. to run provisioning after something screwed up)
vagrant destroy