Skip to content

Commit

Permalink
Update docs with instructions for docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
matteosb committed Jul 10, 2020
1 parent 7c0d949 commit 431adbf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
8 changes: 8 additions & 0 deletions dev-tools/psql
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/bin/bash

# Connect to the docker postgres database with the psql command line tool
# without installing it locally
#
# Sample usage:
# * To open a shell: ./dev-tools/psql
# * Run a query: ./dev-tools/psql -c "SELECT COUNT(*) FROM campaign_contact"

set -euo pipefail

docker-compose exec postgres psql -h localhost -p 5432 -U spoke spokedev "$@"
7 changes: 7 additions & 0 deletions dev-tools/redis-cli
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash
set -euo pipefail

# Connect to the docker redis instance with the redis-cli command line tool
# without installing it locally.
#
# Sample usage:
# * To open a shell: ./dev-tools/redis-cli
# * To clear the cache: ./dev-tools/redis-cli FLUSHDB

docker-compose exec redis redis-cli "$@"
2 changes: 1 addition & 1 deletion docs/EXPLANATION-development-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Generally, label by filename what kind of documentation it is in all-caps, one o
* Reference

## Helpful Dev Tips

* Run `sqlite3 mydb.sqlite` to connect to a SQL shell for the dev database
* [Set up an ESLint plugin in your code editor so that you catch coding errors and follow code style guidelines more easily!](https://medium.com/planet-arkency/catch-mistakes-before-you-run-you-javascript-code-6e524c36f0c8#.oboqsse48)
* [Install the redux-devtools-extension](https://github.com/zalmoxisus/redux-devtools-extension) in Chrome to get advanced Redux debugging features.

## Dependency Management

Expand Down
8 changes: 8 additions & 0 deletions docs/HOWTO-run_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ There are current two ways to run tests, using either PostgreSQL or SQLite.

## PostgreSQL Testing (default, closer to most prod environments)

### Running Postgres with Docker (recommended)

1. Install [Docker](https://docs.docker.com/desktop/)
2. Run redis and postgres using docker-compose: `docker-compose up`
3. Create the test database: `./dev-tools/create-test-database`
4. Run `yarn test`

### Installing Postgres locally
1) Install PostgreSQL - [Tips to installing Postgres](https://www.codementor.io/engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb)
2) In PostgreSQL, create a database and user named "spoke_test":
```
Expand Down
6 changes: 4 additions & 2 deletions docs/HOWTO_USE_POSTGRESQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

To use Postgresql, follow these steps:

1. Either install docker (recommended) or postgresql on your machine:
* If you installed docker run the database using: `docker-compose up`
* If you installed postgres locally, create the spoke dev database: `psql -c "create database spokedev;"`
1. In `.env` set `DB_TYPE=pg`. (Otherwise, you will use sqlite.)
2. Set `DB_PORT=5432`, which is the default port for Postgres.
3. Create the spokedev database: `psql -c "create database spokedev;"`

That's all you need to do initially. The tables will be created the first time the app runs.
That's all you need to do initially. The tables will be created the first time the app runs.

0 comments on commit 431adbf

Please sign in to comment.