Skip to content

See the projected impacts of climate change for where you live.

Notifications You must be signed in to change notification settings

kevinsqi/climatefuture

Repository files navigation

ClimateFuture API

This is the API server that powers climatefuture.io. The frontend code is at kevinsqi/climatefuture-client.

Setup

Go here and create an API key: https://developers.google.com/maps/documentation/geocoding/start#get-a-key

Create a .env file that contains the following:

GOOGLE_MAPS_PLATFORM_KEY=<your api key>

If not using docker-compose to run in development, see MANUAL_SETUP.md to see how to set server up with locally running postgres/postgis.

Running

You'll need Docker installed. In this directory, run:

docker-compose build
docker-compose up

Common dev tasks

Shell into database:

yarn db:shell

Create a new migration and update the DB snapshot:

node_modules/.bin/knex --knexfile ./db/knexfile.js migrate:make [MIGRATION_NAME]
# ...make changes to the migration file...
docker exec -it climatefuture_server_1 yarn run db:migrate
docker exec climatefuture_postgres_1 pg_dump -U climatefuture_user climatefuture > db/init.sql

Common prod tasks

Shell into database:

dokku postgres:connect climatefuture

Running migrations in production:

docker exec -e NODE_ENV=production climatefuture.web.1 yarn run db:migrate

Clearing cached acis_responses table:

dokku postgres:connect climatefuture
delete from acis_responses;

Deploying to production

SSH setup:

Deploying:

  • SSH into dokku droplet: ssh [email protected]
  • Create app: dokku apps:create climatefuture
  • Create postgres plugin if it doesn't exist: sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
  • Create postgres service with postgis image:
    • export POSTGRES_IMAGE="mdillon/postgis"
    • export POSTGRES_IMAGE_VERSION=latest
    • dokku postgres:create climatefuture
    • dokku postgres:connect climatefuture and CREATE EXTENSION postgis;
  • Link postgres to application (this sets DATABASE_URL env var): dokku postgres:link climatefuture climatefuture
  • Add dokku remote: git remote add dokku [email protected]:climatefuture
  • Push to dokku: git push dokku master
  • Load up DB schema and seed data:
    • dokku enter climatefuture
    • cd server
    • yarn run db:load
  • Add domains: dokku domains:add climatefuture api.climatefuture.io
  • Add env vars (find in 1password "ClimateFuture"): dokku config:set climatefuture GOOGLE_MAPS_PLATFORM_KEY=<key>

About

See the projected impacts of climate change for where you live.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages