-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from developmentseed/fix/dev-instructions
Update development instructions
- Loading branch information
Showing
10 changed files
with
217 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
OSM_CONSUMER_KEY=<osm-consumer-key> | ||
OSM_CONSUMER_SECRET=<osm-consumer-secret> | ||
DSN=postgres://postgres@host.docker.internal/osm-teams?sslmode=disable | ||
DSN=postgres://postgres@dev-db/osm-teams?sslmode=disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ node_modules.nosync | |
.idea | ||
hydra-config/prod/prod.yml | ||
.nyc_output | ||
coverage | ||
coverage | ||
docker-data/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v12.16 | ||
14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:lts | ||
FROM node:14 | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,53 +16,30 @@ | |
Check the beta 👉 <!-- markdownlint-disable MD034 -->https://mapping.team | ||
<!-- markdownlint-enable MD034 --> | ||
|
||
## Development | ||
|
||
## Installation | ||
Install requirements: | ||
|
||
### Requirements | ||
- [nvm](https://github.com/creationix/nvm) | ||
- [Docker](https://www.docker.com) | ||
|
||
- [PostgreSQL](https://www.postgresql.org). On OS X, the easiest is to install [Postgres.app](https://postgresapp.com/). | ||
- [Node.js](https://nodejs.org) v12.16+ | ||
- [Docker](https://www.docker.com/) & Docker Compose | ||
Visit your [OpenStreetMap settings](https://www.openstreetmap.org/account/edit) page and register an OAuth1 Client App: | ||
|
||
### Setting up Hydra | ||
![OSM Client App](oauth1-osm-client-app.png "OAuth1 page at OSM Website") | ||
|
||
1. Create the database for tokens | ||
|
||
```bash | ||
createdb osm-teams | ||
createdb osm-teams-test | ||
``` | ||
|
||
For the rest of this documentation, we will assume that the database location is `postgres://postgres@localhost/osm-teams?sslmode=disable` on your local machine. Inside docker, that location is `postgres://[email protected]/osm-teams?sslmode=disable` | ||
|
||
1. Create an `.env` file by copying `.env.sample` and replacing the values as needed. `OSM_CONSUMER_KEY` and `OSM_CONSUMER_SECRET` are values obtained by creating a new OAuth app on openstreetmap.org. The .env file can contain: | ||
Create an `.env` file by copying `.env.sample` and replacing the values as needed. `OSM_CONSUMER_KEY` and `OSM_CONSUMER_SECRET` are values available at the OAuth app page on openstreetmap.org. The .env file should contain: | ||
|
||
```bash | ||
OSM_CONSUMER_KEY=<osm-teams-app> | ||
OSM_CONSUMER_SECRET=<osm-teams-app-secret> | ||
DSN=postgres://[email protected]/osm-teams?sslmode=disable | ||
``` | ||
|
||
1. Build the docker images: | ||
|
||
```bash | ||
docker-compose -f compose.yml build | ||
``` | ||
|
||
1. Start Hydra and the server | ||
|
||
```bash | ||
docker-compose -f compose.yml -f compose.dev.yml up | ||
DSN=postgres://postgres@dev-db/osm-teams?sslmode=disable | ||
``` | ||
|
||
⚠️ In development, `docker-compose -f compose.yml -f compose.dev.yml up` enables hot module reloading while you make modifications to the code. `docker-compose up` should be used for production/staging deployments. | ||
|
||
This will start hydra where the token issuer is at `http://localhost:4444` and the admin interface is at `http://localhost:4445`. This also sets up the consent and login interface at `http://localhost:8989` (where we will create a first-party oauth app) | ||
Start Hydra and PostgreSQL with Docker: | ||
|
||
### Setting up the OSM-teams app | ||
docker-compose -f compose.dev.yml up --build | ||
|
||
Create the [first-party](https://auth0.com/docs/applications/concepts/app-types-first-third-party) "manage" app | ||
On a separate terminal, create the [first-party](https://auth0.com/docs/applications/concepts/app-types-first-third-party) "manage" app: | ||
|
||
```bash | ||
docker-compose exec hydra hydra clients create --endpoint http://localhost:4445 \ | ||
|
@@ -74,6 +51,22 @@ docker-compose exec hydra hydra clients create --endpoint http://localhost:4445 | |
--callbacks http://localhost:8989/login/accept | ||
``` | ||
|
||
Install Node.js the required version (see [.nvmrc](.nvmrc) file): | ||
|
||
nvm i | ||
|
||
Install Node.js modules: | ||
|
||
yarn | ||
|
||
Migrate `dev-db` database: | ||
|
||
yarn migrate | ||
|
||
Start development server: | ||
|
||
yarn dev | ||
|
||
<!-- markdownlint-disable MD034 --> | ||
✨ You can now login to the app at http://localhost:8989 | ||
<!-- markdownlint-enable MD034 --> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,61 @@ | ||
version: '3.7' | ||
|
||
services: | ||
teams: | ||
build: . | ||
hydra: | ||
image: oryd/hydra:v1.9.2 | ||
ports: | ||
- 8989:8989 | ||
- 3007:3007 | ||
- 4444:4444 | ||
- 4445:4445 | ||
- 5555:5555 | ||
command: | ||
serve -c /etc/config/hydra/hydra.yml all --dangerous-force-http | ||
volumes: | ||
- .:/usr/src/app | ||
- ./node_modules:/usr/src/app/node_modules | ||
- | ||
type: bind | ||
source: ./hydra-config/dev | ||
target: /etc/config/hydra | ||
env_file: | ||
.env | ||
depends_on: | ||
- hydra-migrate | ||
restart: always | ||
|
||
hydra-migrate: | ||
image: oryd/hydra:v1.9.2 | ||
command: | ||
npm run dev | ||
migrate -c /etc/config/hydra/hydra.yml sql -e --yes | ||
volumes: | ||
- | ||
type: bind | ||
source: ./hydra-config/dev | ||
target: /etc/config/hydra | ||
env_file: | ||
.env | ||
restart: on-failure | ||
|
||
dev-db: | ||
platform: linux/amd64 | ||
image: mdillon/postgis:9.6-alpine | ||
restart: 'always' | ||
ports: | ||
- 5433:5432 | ||
environment: | ||
- ALLOW_IP_RANGE=0.0.0.0/0 | ||
- POSTGRES_DB=osm-teams | ||
- PGDATA=/opt/postgres/data | ||
volumes: | ||
- ./docker-data/dev-db:/opt/postgres/data | ||
|
||
test-db: | ||
platform: linux/amd64 | ||
image: mdillon/postgis:9.6-alpine | ||
restart: 'always' | ||
ports: | ||
- 5434:5432 | ||
environment: | ||
- ALLOW_IP_RANGE=0.0.0.0/0 | ||
- POSTGRES_DB=osm-teams-test | ||
- PGDATA=/opt/postgres/data | ||
volumes: | ||
- ./docker-data/test-db:/opt/postgres/data | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.