Skip to content

Commit

Permalink
Update datastore READMEs + add config for eventstore (warrant-dev#43)
Browse files Browse the repository at this point in the history
* In mysql README, remove migrate-datastore step and add eventstore config to docker compose example + update steps in 'Running the Binary' section

* In postgres README, remove migrate-datastore step and add eventstore config to docker compose example + update steps in 'Running the Binary' section
  • Loading branch information
kkajla12 authored Mar 25, 2023
1 parent 85aa321 commit 9383fe6
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 54 deletions.
67 changes: 40 additions & 27 deletions migrations/datastore/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,39 @@ The following [Docker Compose](https://docs.docker.com/compose/) manifest will c
```yaml
version: "3.9"
services:
datastore:
database:
image: mysql:8.0.32
environment:
MYSQL_USER: replace_with_username
MYSQL_PASSWORD: replace_with_password
MYSQL_DATABASE: warrant
ports:
- 3306:3306
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 5s
retries: 10

migrate-datastore:
image: migrate/migrate
command:
[
"-source",
"github://warrant-dev/warrant/migrations/datastore/mysql",
"-database",
"mysql://replace_with_username:replace_with_password@tcp(datastore:3306)/warrant",
"up",
]
depends_on:
datastore:
condition: service_healthy

web:
image: warrantdev/warrant
ports:
- 8000:8000
depends_on:
migrate-datastore:
condition: service_completed_successfully
database:
condition: service_healthy
environment:
WARRANT_PORT: 8000
WARRANT_LOGLEVEL: 1
WARRANT_ENABLEACCESSLOG: "true"
WARRANT_DATASTORE: mysql
WARRANT_DATASTORE_MYSQL_USERNAME: replace_with_username
WARRANT_DATASTORE_MYSQL_PASSWORD: replace_with_password
WARRANT_DATASTORE_MYSQL_HOSTNAME: datastore
WARRANT_DATASTORE_MYSQL_HOSTNAME: database
WARRANT_DATASTORE_MYSQL_DATABASE: warrant
WARRANT_EVENTSTORE: mysql
WARRANT_EVENTSTORE_MYSQL_USERNAME: replace_with_username
WARRANT_EVENTSTORE_MYSQL_PASSWORD: replace_with_password
WARRANT_EVENTSTORE_MYSQL_HOSTNAME: database
WARRANT_EVENTSTORE_MYSQL_DATABASE: warrantEvents
WARRANT_API_KEY: replace_with_api_key
```
Expand All @@ -61,22 +51,45 @@ services:
Follow the [MySQL Installation Guide](https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/) for your OS to install and start MySQL. For MacOS users, we recommend [installing MySQL using homebrew](https://formulae.brew.sh/formula/mysql).
### Migrate the Database Schema
### Download the Binary
Once you've setup and started your database, you can setup the database schema using [golang-migrate](https://github.com/golang-migrate/migrate).
Migrate to the latest schema:
Download the latest warrant binary for your architecture from [here](https://github.com/warrant-dev/warrant/releases/latest). Then unzip the tarball and run the `warrant` executable.

```bash
migrate -source github://warrant-dev/warrant/migrations/datastore/mysql -database mysql://replace_with_username@/warrant up
tar -xvf <name_of_tarball>
```

### Download and Run the Binary
### Create `warrant.yaml` Configuration

Download the latest warrant binary for your architecture from [here](https://github.com/warrant-dev/warrant/releases/latest). Then unzip the tarball and run the `warrant` executable.
Create a file called `warrant.yaml` in the directory containing the Warrant binary.

```bash
tar -xvf <name_of_tarball>
cd <path_to_untarred_directory>
touch warrant.yaml
```

```yaml
# warrant.yaml
port: 8000
logLevel: 0
enableAccessLog: "true"
apiKey: replace_with_api_key
datastore:
mysql:
username: replace_with_username
password: replace_with_password
hostname: 127.0.0.1
database: warrant
eventstore:
mysql:
username: replace_with_username
password: replace_with_password
hostname: 127.0.0.1
database: warrantEvents
```

### Run the Binary

```bash
./warrant
```
70 changes: 43 additions & 27 deletions migrations/datastore/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,40 @@ The following [Docker Compose](https://docs.docker.com/compose/) manifest will c
```yaml
version: "3.9"
services:
datastore:
database:
image: postgres:14.7
environment:
POSTGRES_PASSWORD: replace_with_password
POSTGRES_DB: warrant
ports:
- 5432:5432
healthcheck:
test: ["CMD", "pg_isready", "-d", "warrant"]
timeout: 5s
retries: 10

migrate-datastore:
image: migrate/migrate
command:
[
"-source",
"github://warrant-dev/warrant/migrations/datastore/postgres",
"-database",
"postgres://postgres:replace_with_password@datastore/warrant?sslmode=disable",
"up",
]
depends_on:
datastore:
condition: service_healthy

web:
image: warrantdev/warrant
ports:
- 8000:8000
depends_on:
migrate-datastore:
condition: service_completed_successfully
database:
condition: service_healthy
environment:
WARRANT_PORT: 8000
WARRANT_LOGLEVEL: 1
WARRANT_ENABLEACCESSLOG: "true"
WARRANT_DATASTORE: postgres
WARRANT_DATASTORE_POSTGRES_USERNAME: postgres
WARRANT_DATASTORE_POSTGRES_PASSWORD: replace_with_password
WARRANT_DATASTORE_POSTGRES_HOSTNAME: datastore
WARRANT_DATASTORE_POSTGRES_HOSTNAME: database
WARRANT_DATASTORE_POSTGRES_DATABASE: warrant
WARRANT_DATASTORE_POSTGRES_SSLMODE: disable
WARRANT_EVENTSTORE: postgres
WARRANT_EVENTSTORE_POSTGRES_USERNAME: postgres
WARRANT_EVENTSTORE_POSTGRES_PASSWORD: replace_with_password
WARRANT_EVENTSTORE_POSTGRES_HOSTNAME: database
WARRANT_EVENTSTORE_POSTGRES_DATABASE: warrant_events
WARRANT_EVENTSTORE_POSTGRES_SSLMODE: disable
WARRANT_API_KEY: replace_with_api_key
```
Expand All @@ -61,22 +52,47 @@ services:
Install and run the [PostgreSQL Installer](https://www.postgresql.org/download/) for your OS to install and start PostgreSQL. For MacOS users, we recommend [installing PostgreSQL using homebrew](https://formulae.brew.sh/formula/postgresql@14).
### Migrate the Database Schema
### Download the Binary
Once you've setup and started your database, you can setup the database schema using [golang-migrate](https://github.com/golang-migrate/migrate).
Migrate to the latest schema:
Download the latest warrant binary for your architecture from [here](https://github.com/warrant-dev/warrant/releases/latest). Then unzip the tarball and run the `warrant` executable.

```bash
migrate -source github://warrant-dev/warrant/migrations/datastore/postgres -database postgres://postgres:replace_with_password@/warrant?sslmode=disable up
tar -xvf <name_of_tarball>
```

### Download and Run the Binary
### Create `warrant.yaml` Configuration

Download the latest warrant binary for your architecture from [here](https://github.com/warrant-dev/warrant/releases/latest). Then unzip the tarball and run the `warrant` executable.
Create a file called `warrant.yaml` in the directory containing the Warrant binary.

```bash
tar -xvf <name_of_tarball>
cd <path_to_untarred_directory>
touch warrant.yaml
```

```yaml
# warrant.yaml
port: 8000
logLevel: 0
enableAccessLog: "true"
apiKey: replace_with_api_key
datastore:
postgres:
username: replace_with_username
password: replace_with_password
hostname: localhost
database: warrant
sslmode: disable
eventstore:
postgres:
username: replace_with_username
password: replace_with_password
hostname: localhost
database: warrant_events
sslmode: disable
```

### Run the Binary

```bash
./warrant
```

0 comments on commit 9383fe6

Please sign in to comment.