-
Notifications
You must be signed in to change notification settings - Fork 3
Local Development
-
Install Node.js (version 12.0.0).
-
Install
yarn
(version >=1.19.x):npm install yarn@latest -g
-
Install Dependencies:
yarn install
-
Set up local database: Local Database Setup
-
Download Heroku CLI and make a Heroku account if you do not have one. You will need to be added to the Heroku app "teacher-moments-staging".
-
Set up local environment configuration
- This is the list of all environment variables that are are pre-populated in
config/dev
, need to be exported prior to running the Teacher Moments server:ENV=dev
- Run
heroku config --app teacher-moments-staging --shell
and copy the output for the following intoconfig/dev-heroku-secrets
:AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... DATABASE_URL=... DCSS_BRAND_LANDING_PAGE_URL=... DCSS_BRAND_LOGO=... DCSS_BRAND_NAME_TITLE=... DCSS_BRAND_OWNER=... ENV=... HEROKU_POSTGRESQL_ORANGE_URL=... NEW_RELIC_LICENSE_KEY=... NEW_RELIC_LOG=... NODE_ENV=... PAPERTRAIL_API_TOKEN=... PGDATABASE=... PGHOST=... PGPASSWORD=... PGSSLMODE=... PGUSER=... REDIS_TLS_URL=... REDIS_URL=... REDIS_USE_SSL=... S3_BUCKET=... SENDGRID_API_KEY=... SENDGRID_PASSWORD=... SENDGRID_SENDER=... SENDGRID_USERNAME=... SESSION_SECRET=... SQL_DEBUG=... WATSON_KEY=... WATSON_SPEECHTOTEXT_KEY=... WATSON_SPEECHTOTEXT_URL=... WATSON_URL=... WATSON_VISREC_KEY=... WATSON_VISREC_URL=...
- This is the list of all environment variables that are are pre-populated in
-
Start the development server
- If you are using Mac or Linux, export the required environment variables first:
source config/dev; source config/dev-heroku-secrets;
- And then run the dev server with:
...You should see your local site at http://localhost:3000.
yarn dev
- If you are using Mac or Linux, export the required environment variables first:
This project uses Eslint for linting. To catch syntax and style errors, run
yarn lint
This linting command also runs on Travis CI when you submit a PR.
-
Export
config/dev
source config/dev;
You may need to run:
export PGUSER=`whoami`;
-
Install PostgreSQL (unless already installed)
- Make sure that the Postgres version installed is 11.4
- Mac:
brew install postgres
- Ubuntu (based on https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04)
sudo apt-get update && sudo apt-get install postgresql postgresql-contrib
-
Start PostgreSQL and make yourself a default database
- Mac:
brew services start postgresql createdb # creates a default database under your user name
- Linux
sudo su postgres createuser --interactive # enter your username and make yourself a super user su yourusername createdb # creates a default database under the current user
- Mac:
-
Initialize local database
-
The following should be run with a
$PGUSER
&$PGPASSWORD
for a super user who can create databases and roles (see step 1):yarn db-init:dev
This command creates a database called
teachermoments
and then sets up a role called tm and then creates all of the tables inteachermoments
.To do this manually, create a database called
teachermoments
:createdb teachermoments
Then create the role
tm
with a passwordteachermoments
, then run:yarn db-migrate-up
-
- In the terminal, start teacher moments with the correct env vars and sql debugging enabled:
export $(cat config/dev); SQL_DEBUG=1 yarn dev;
- Then create a super admin user with the following command for a NEW user, you cannot run this command on an existing user. Put the new super admin's account details in the double quotes before running.
yarn workspace server seed:super-admin email="" username="" password=""
You can now log in as your super user and adjust permissions for any other user as needed.