- Python >= 3.4
- pip
- virtualenv/virtualenvwrapper
sudo pip install virtualenvwrapper- add
source /usr/local/bin/virtualenvwrapper.shto your shell config (.bashrs or .zshrs) - restart your terminal
- copy settings/local_example.py to settings/local.py.
cp conf/settings/local_example.py conf/settings/local.py
- copy settings/.env.default_local to settings/.env
cp conf/settings/.env.default_local conf/settings/.env
mkvirtualenv pompomorworkon pompompip install -r requirements/local.txtexport DJANGO_SETTINGS_MODULE=conf.settings.local./manage.py migrate
./manage.py runserver
py.test
Install nodejs and run npm install
- pylint:
sh scripts/python_lint.sh - cpd:
sh scripts/jscpd.sh - eslint:
sh scripts/eslint.sh
- Download the binary from git-hooks and append it to your PATH.
- Install hooks:
git hooks install
- config virtualenv created before as the virtualenv of the project (settings -> python interpreter)
- enable django support: settings -> django
- django project root: /home/diego/dev/projects/python/pompom
- settings: conf/settings/local.py
- manage script: manage.py
- mark directory Templates as "Templates folder" (right-click over directory in the "Project view")
- Go to the Resources tab
- Under the Add-ons section search for
Heroku Postgres - Select a Plan name. Hobby tier might be enough for the application needs, but you should check: https://devcenter.heroku.com/articles/heroku-postgres-plans
- Go to the Settings tab
- In the Config Variables click Reveal
- If you added the Postgres instance correctly you should see a
DATABASE_URLentry. - Add an entry named
DJANGO_SETTINGS_MODULEwith the valueconf.settings.production - Add an entry named
RAVEN_DSNwith the Sentry logging URL.
Gitlab already has a configured pipeline to make deployment easy and secure. Once you have tested the application on the staging environment and you are read to deploy, follow these steps:
- Create a tag in git.
git tag v0.1.0 - Push it to gitlab's remote.
git push --tags - A new pipeline will run in Gitlab, once it succeeds you can manual deploy to production using the Deploy button.
- Make sure you have successfully deployed and tested the current version to the staging environment.
- Locally run CI tasks. Including eslint, jscpd, tests and migrations.
- Create a tag in git.
git tag v0.1.0 - Push it to gitlab's remote.
git push --tags - Create a heroku remote if you haven't already:
**
heroku git:remote -a pompom-prod - Deploy to heroku using
git push heroku master - Add a superuser to the application in order to access the backend
heroku run python manage.py createsuperuser
Follow the Heroku instructions here: https://devcenter.heroku.com/articles/custom-domains#configuring-dns-for-root-domains
For GoDaddy, the root domain needs to be 'forwarded' with GoDaddy's tools, rather than a specific record.
In order to enable automatic ssl management, be sure to use the '.herokudns.com' domains when forwarding
The admin password recovery feature sends email, which is configured in Heroku to use mailgun. https://elements.heroku.com/addons/mailgun
heroku addons:create mailgun:free
The free tier is good for up to 10,000 emails per month.
Prod environments should override the DJANGO_EMAIL_BACKEND environment variable to enable sending real emails.
Emails won't work generally for the dev account, unless you go to mailgun (via heroku) and add your account as an Authorized Recipient.
To enable emails, set the heroku env variables like so: EMAIL_HOST=$MAILGUN_SMPT_SERVER EMAIL_PORT=$MAILGUN_SMTP_PORT EMAIL_HOST_USER=$MAILGUN_SMTP_LOGIN EMAIL_HOST_PASSWORD=$MAILGUN_SMTP_PASSWORD
When adding the txt/mx records described here https://app.mailgun.com/app/domains/mg.pompomapp.net/verify godaddy showed an error when saving, but saved the records anyway.