This is the API server that powers climatefuture.io. The frontend code is at kevinsqi/climatefuture-client.
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.
You'll need Docker installed. In this directory, run:
docker-compose build
docker-compose up
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
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;
SSH setup:
- Upload your public ssh key to the droplet to be able to SSH into droplet with
ssh [email protected] - Add your SSH key to dokku to be able to run
git push dokku master
- 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=latestdokku postgres:create climatefuturedokku postgres:connect climatefutureandCREATE EXTENSION postgis;
- Link postgres to application (this sets
DATABASE_URLenv 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 climatefuturecd serveryarn 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>