Skip to content

Commit

Permalink
Merge pull request #6 from andela/ch-deploy-base-heroku-164046242
Browse files Browse the repository at this point in the history
#164046242 Initial Deployment of  Legion-backend to Heroku
  • Loading branch information
abulojoshua1 committed Feb 28, 2019
2 parents e012e25 + 3b51f22 commit dc8c118
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*.swp

# Byte-compiled / optimized / DLL files

.DS_Store
__pycache__/
*.py[cod]
*$py.class
Expand Down
4 changes: 4 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
release: python manage.py makemigrations --settings=authors.settings.prod
release: python manage.py migrate --settings=authors.settings.prod

web: gunicorn authors.wsgi
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,41 @@ Authors Haven - A Social platform for the creative at heart.
Create a community of like minded authors to foster inspiration and innovation
by leveraging the modern web.

---
## Running the app.
Authors Haven app can be run by:
### STEP 1:
Git clone this repository: `git clone https://github.com/andela/ah-legion-backend.git`

### STEP 2:
Change your working directory to the app's root. `cd ah-legion-backend`

### STEP 3:
Create a virtual environment and activate it.
Install all the requirements by running `pip install -r requirements.txt`
Create an environment file with environment variables in the following format:

SECRET_KEY=supersecretkey
DEBUG=True
DB_NAME=yourdbname
DB_USER=yourname
DB_PASSWORD=yourstrongpassword
DB_HOST=127.0.0.1

### STEP 4:
Run the app according to the environment you need:

#### Development environment:
`python manage.py runserver --settings=authors.settings.dev`

#### Testing environment:
`python manage.py test --settings=authors.settings.test`

#### Production environment:
The run the app on a production environment:
Use Postman to acccess the app by using this url as your domain:
`https://ah-legion.herokuapp.com`

Input appropriate endpoint urls, enjoy.

## API Spec
The preferred JSON object to be returned by the API should be structured as follows:
Expand Down Expand Up @@ -393,7 +427,3 @@ No additional parameters required
### Get Tags

`GET /api/tags`




Empty file.
3 changes: 2 additions & 1 deletion authors/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '7pgozr2jn7zs_o%i8id6=rddie!*0f0qy3$oy$(8231i^4*@u3'
SECRET_KEY = config('SECRET_KEY', default = '#dfhewy73twy3e88Y@Y828Y@91')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -47,6 +47,7 @@

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down
5 changes: 5 additions & 0 deletions authors/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = config('ALLOWED_HOSTS')

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, "static")

DATABASES = {
'default': dj_database_url.config(
Expand Down
2 changes: 1 addition & 1 deletion authors/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "authors.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "authors.settings.prod")

application = get_wsgi_application()
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Django==2.1.7
django-cors-middleware==1.3.1
django-extensions==2.1.6
djangorestframework==3.9.1
gunicorn==19.9.0
psycopg2-binary==2.7.7
PyJWT==1.4.2
python-decouple==3.1
coverage==4.5.2
whitenoise==4.1.2
1 change: 1 addition & 0 deletions runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.7.2

0 comments on commit dc8c118

Please sign in to comment.