Skip to content

Commit

Permalink
ch-deploy-to-heroku-157842572
Browse files Browse the repository at this point in the history
chore(heroku): Configure settings for deployment
Add Procfile for heroku deployment

Add whitenoise, gunicorn, psycopg2 dependencies to requirements.txt

Add whitenoise instance to wsgi

Add a settings.py file

Add database configurations to settings global

[Finishes #157842572]
  • Loading branch information
tibetegya committed May 31, 2018
1 parent d8ae3f3 commit 2b87e99
Show file tree
Hide file tree
Showing 17 changed files with 346 additions and 25 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ coverage.xml

# Django stuff:
*.log
settings*.py
#settings*.py
local_settings.py
*.sqlite
/CACHE

Expand All @@ -62,3 +63,6 @@ target/
# External Libraries
wger/core/static/bower_components
node_modules
*.DS_Store
.vscode/
package-lock.json
34 changes: 14 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ sudo: false
# Python versions to test
python:
- "2.7"
- "3.4"
- "3.5"

services:
- postgresql

# Manually define here the combinations environment variables to test
# https://github.com/travis-ci/travis-ci/issues/1519
env:
- TEST_MOBILE=True DB=postgresql TRAVIS_NODE_VERSION="4"
- TEST_MOBILE=True DB=sqlite TRAVIS_NODE_VERSION="4"
- TEST_MOBILE=False DB=postgresql TRAVIS_NODE_VERSION="4"
- TEST_MOBILE=False DB=sqlite TRAVIS_NODE_VERSION="4"
- TRAVIS_NODE_VERSION="4"

# Install the application
install:
Expand All @@ -39,32 +38,27 @@ install:

# Install requirements
- pip install -r requirements_devel.txt
- pip install coverage
- pip install coveralls
- npm install
- if [[ "$DB" = "postgresql" ]]; then pip install psycopg2; fi

# Setup application
- if [[ "$DB" = "sqlite" ]]; then invoke create_settings; fi
- if [[ "$DB" = "postgresql" ]]; then invoke create_settings --database-type postgresql; fi
- invoke create-settings --database-type postgresql

# Create test databases
before_script:
- if [[ "$DB" = "postgresq" ]]; then psql -c 'DROP DATABASE IF EXISTS test_wger;' -U postgres; fi
- if [[ "$DB" = "postgresql" ]]; then psql -c 'CREATE DATABASE test_wger;' -U postgres; fi

#slack notifications
travis encrypt "andela:ULPqfRnWEWmLpQThku9rgqLu" --add notifications.slack
- psql -c 'DROP DATABASE IF EXISTS test_wger;' -U postgres
- psql -c 'CREATE DATABASE test_wger;' -U postgres

# Do the tests
script:
# Formatting
- pep8 wger

# Javascript linting
- gulp lint

# Regular application
- coverage run --source='.' ./manage.py test


# Code coverage
- coverage report
- coveralls

#slack notifications
notifications:
slack: andela:ULPqfRnWEWmLpQThku9rgqLu
4 changes: 4 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
release: npm install
release: python setup.py develop
release: invoke bootstrap-wger --settings-path /app/settings.py --no-start-server
web: gunicorn wger.wsgi:application
41 changes: 41 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "wg-rogue-one",
"scripts": {
},
"env": {
"DISABLE_COLLECTSTATIC": {
"required": true
},
"WG_HOST": {
"required": true
},
"WG_KEY": {
"required": true
},
"WG_NAME": {
"required": true
},
"WG_PASSWORD": {
"required": true
},
"WG_USER": {
"required": true
}
},
"formation": {
"web": {
"quantity": 1
}
},
"addons": [
"heroku-postgresql"
],
"buildpacks": [
{
"url": "heroku/nodejs"
},
{
"url": "heroku/python"
}
]
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
"eslint-plugin-react": "^6.1.2",
"gulp": "^3.9.1",
"gulp-eslint": "^3.0.1"
},
"dependencies": {
"bower": "^1.8.4"
}
}
7 changes: 6 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

Django>=1.9,<1.10
django-recaptcha
django-recaptcha==1.3.1
reportlab
django_mobile
django-formtools>=1.0,<1.1
Expand All @@ -19,6 +19,11 @@ django-sortedm2m
django-bower
invoke
requests
whitenoise
gunicorn
psycopg2-binary
dj-database-url==0.4.2
dj-static==0.0.6

# REST API
djangorestframework>=3.2,<3.3
Expand Down
59 changes: 59 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from wger.settings_global import *

# Use 'DEBUG = True' to get more details for server errors
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = True

ADMINS = (
('Your name', 'your_email@example.com'),
)
MANAGERS = ADMINS


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('WG_NAME') or "'test_wger'",
'USER': os.environ.get('WG_USER') or 'postgres',
'HOST': os.environ.get('WG_HOST') or 'localhost',
'PASSWORD': os.environ.get('WG_PASSWORD') or '',
'PORT': os.environ.get('WG_PORT') or '',
}
}

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'rh(nd%tb*7zl-*j&6h812littid0w47npbtwm1nmed6kp$wir6'

# Your reCaptcha keys
RECAPTCHA_PUBLIC_KEY = ''
RECAPTCHA_PRIVATE_KEY = ''
NOCAPTCHA = True

# The site's URL (e.g. http://www.my-local-gym.com or http://localhost:8000)
# This is needed for uploaded files and images (exercise images, etc.) to be
# properly served.
SITE_URL = 'http://localhost:8000'

# Path to uploaded files
# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = '/Users/tibzy/.local/share/wger/media'
MEDIA_URL = '/media/'

# Allow all hosts to access the application. Change if used in production.
ALLOWED_HOSTS = '*'

# This might be a good idea if you setup memcached
#SESSION_ENGINE = "django.contrib.sessions.backends.cache"

# Configure a real backend in production
if DEBUG:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Sender address used for sent emails
WGER_SETTINGS['EMAIL_FROM'] = 'wger Workout Manager <wger@example.com>'

# Your twitter handle, if you have one for this instance.
#WGER_SETTINGS['TWITTER'] = ''
20 changes: 20 additions & 0 deletions wger/config/migrations/0002_auto_20180530_1412.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-05-30 11:12
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('config', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='languageconfig',
name='item',
field=models.CharField(choices=[('1', 'Exercises'), ('2', 'Ingredients')], editable=False, max_length=2),
),
]
20 changes: 20 additions & 0 deletions wger/core/migrations/0010_auto_20180530_1412.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-05-30 11:12
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0009_auto_20160303_2340'),
]

operations = [
migrations.AlterField(
model_name='license',
name='full_name',
field=models.CharField(help_text='If a license has been localized, e.g. the Creative Commons licenses for the different countries, add them as separate entries here.', max_length=60, verbose_name='Full name'),
),
]
25 changes: 25 additions & 0 deletions wger/email/migrations/0002_auto_20180530_1412.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-05-30 11:12
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('email', '0001_initial'),
]

operations = [
migrations.AlterModelOptions(
name='log',
options={'ordering': ['-date']},
),
migrations.AlterField(
model_name='log',
name='gym',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='email_log', to='gym.Gym'),
),
]
45 changes: 45 additions & 0 deletions wger/exercises/migrations/0004_auto_20180530_1412.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-05-30 11:12
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('exercises', '0003_auto_20160921_2000'),
]

operations = [
migrations.AlterField(
model_name='exercise',
name='equipment',
field=models.ManyToManyField(blank=True, to='exercises.Equipment', verbose_name='Equipment'),
),
migrations.AlterField(
model_name='exercise',
name='muscles',
field=models.ManyToManyField(blank=True, to='exercises.Muscle', verbose_name='Primary muscles'),
),
migrations.AlterField(
model_name='exercise',
name='muscles_secondary',
field=models.ManyToManyField(blank=True, related_name='secondary_muscles', to='exercises.Muscle', verbose_name='Secondary muscles'),
),
migrations.AlterField(
model_name='exercise',
name='status',
field=models.CharField(choices=[('1', 'Pending'), ('2', 'Accepted'), ('3', 'Declined')], default='1', editable=False, max_length=2),
),
migrations.AlterField(
model_name='exerciseimage',
name='is_main',
field=models.BooleanField(default=False, help_text='Tick the box if you want to set this image as the main one for the exercise (will be shown e.g. in the search). The first image is automatically marked by the system.', verbose_name='Main picture'),
),
migrations.AlterField(
model_name='exerciseimage',
name='status',
field=models.CharField(choices=[('1', 'Pending'), ('2', 'Accepted'), ('3', 'Declined')], default='1', editable=False, max_length=2),
),
]
34 changes: 34 additions & 0 deletions wger/gym/migrations/0007_auto_20180530_1412.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-05-30 11:12
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('gym', '0006_auto_20160214_1013'),
]

operations = [
migrations.AlterModelOptions(
name='gym',
options={'ordering': ['name'], 'permissions': (('gym_trainer', 'Trainer: can see the users for a gym'), ('manage_gym', 'Admin: can manage users for a gym'), ('manage_gyms', 'Admin: can administrate the different gyms'))},
),
migrations.AlterField(
model_name='contract',
name='options',
field=models.ManyToManyField(blank=True, to='gym.ContractOption', verbose_name='Options'),
),
migrations.AlterField(
model_name='gymadminconfig',
name='overview_inactive',
field=models.BooleanField(default=True, help_text='Receive email overviews of inactive members', verbose_name='Overview of inactive members'),
),
migrations.AlterField(
model_name='gymconfig',
name='weeks_inactive',
field=models.PositiveIntegerField(default=4, help_text='Number of weeks since the last time a user logged his presence to be considered inactive', verbose_name='Reminder of inactive members'),
),
]
21 changes: 21 additions & 0 deletions wger/manager/migrations/0008_auto_20180530_1412.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-05-30 11:12
from __future__ import unicode_literals

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('manager', '0007_auto_20160311_2258'),
]

operations = [
migrations.AlterField(
model_name='setting',
name='reps',
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(600)], verbose_name='Amount'),
),
]
Loading

1 comment on commit 2b87e99

@peterwade153
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all looks good.

Please sign in to comment.