This repo contains the Lighten API which runs on Heroku at https://lighten-api.herokuapp.com/.
The steps here only need to be run once.
-
Install Docker for Mac from https://docs.docker.com/docker-for-mac/
-
Install the Heroku CLI
brew install heroku
-
Clone the
lighten-api
repo and submodulesgit clone [email protected]:sfbrigade/lighten-api.git cd lighten-api git submodule update --init --recursive
-
Create an
.env
file for holding environment variablesecho "SECRET_KEY=$(openssl rand -hex 24)" > .env
-
Bring up the development services
docker-compose up -d
-
Initialize the database
docker-compose exec api python manage.py migrate
-
Load initial data via fixtures
docker-compose exec api python manage.py loaddata lighten_api/organization
-
Create a superuser
docker-compose exec api python manage.py createsuperuser
-
Stop the development services
docker-compose stop
-
Bring up the development services
docker-compose up --build
The
--build
option ensures any new dependencies are included. -
Open the development API
open http://localhost:8080
-
Run tests as needed
docker-compose exec api python manage.py test
If you make any changes to the data models, you'll need to commit migrations
docker-compose exec api python manage.py makemigrations
git add */migrations
git commit
-
Deploy to Heroku
git push heroku master
-
Open the production API
heroku open
If you made any changes to the data models, you'll need to apply migrations
heroku run python manage.py migrate
docker-compose exec api bin/import-dataset development
docker-compose exec api bin/import-dataset production
For more information about using Python and Docker on Heroku, see these Dev Center articles: