Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinsqi/climatefuture
See the projected impacts of climate change for where you live.
https://github.com/kevinsqi/climatefuture
climate-change
Last synced: about 1 month ago
JSON representation
See the projected impacts of climate change for where you live.
- Host: GitHub
- URL: https://github.com/kevinsqi/climatefuture
- Owner: kevinsqi
- Created: 2019-10-17T21:37:27.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T01:51:07.000Z (almost 2 years ago)
- Last Synced: 2024-10-16T13:22:10.383Z (3 months ago)
- Topics: climate-change
- Language: TSQL
- Homepage: https://www.climatefuture.io
- Size: 4.94 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ClimateFuture API
This is the API server that powers [climatefuture.io](https://www.climatefuture.io/). The frontend code is at [kevinsqi/climatefuture-client](https://github.com/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=
```If not using docker-compose to run in development, see [MANUAL_SETUP.md](./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:
* [Upload your public ssh key](https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/) to the droplet to be able to SSH into droplet with `ssh [email protected]`
* [Add your SSH key to dokku](http://dokku.viewdocs.io/dokku/deployment/user-management/#adding-ssh-keys) to be able to run `git push dokku master`[Deploying](http://dokku.viewdocs.io/dokku~v0.12.13/deployment/application-deployment/):
* 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=`